我一直在努力改善Rails 3中的页面加载时间,我经历了几个blogs,在那里我了解到我可以包含 css , js 分别在 application.css 和 application.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" %>
答案 0 :(得分:0)
如果您使用
*= require_tree .
它会加载 app / assets / stylesheet 中的所有css文件,因此不需要提及每个文件名。
还需要注意的是,在更新application.css和application.js文件后需要重新启动服务器。希望这有帮助。