我一直在努力改善 Rails 3 中的页面加载时间,我经历了几次 blogs我了解到我可以分别在 application.css 和 application.js 中包含 css、js 文件名.
出于测试目的,我从布局中删除了文件并将其包含在 application.css 中,然后在页面重新加载时 css 文件没有重新加载。
我当前的 application.css 文件:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require 'owl.carousel.min.css'
*= require 'owl.carousel.min.css'
*= require 'owl.theme.min.css'
*= require "flag-sprites.min.css"
*= require 'owl.transitions.min.css'
*/
layout.html.erb:
<%= stylesheet_link_tag "application.css" %>
最佳答案
如果你使用
*= require_tree .
它将加载 app/assets/stylesheet 中的所有 css 文件,因此无需提及每个文件名。
还有一点要注意,更新application.css和application.js文件后需要重启服务器。希望对您有所帮助。
关于javascript - 如何合并多个 css、js 文件并在 rails 3 中作为一个文件使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38304783/