【发布时间】:2016-07-11 10:34:12
【问题描述】:
我一直在尝试改善 Rails 3 中的页面加载时间,我经历了几次blogs,在那里我了解到我可以包含 css、js 文件application.css 和 application.js 中的名称。
出于测试目的,我从布局中删除了文件并将其包含在 application.css 中,然后在页面重新加载时 css 文件没有重新加载。 p>
我当前的 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" %>
【问题讨论】:
-
主要问题是什么?
-
通过使用上面的代码,上面提到的css文件没有加载。
-
删除 .css 并且不要使用 quot 和
require -
我从文件名中删除了引号和 .css,但没有帮助。我想要实现的是将多个文件作为一个文件提供,从而减少请求的数量。
-
你在生产环境中测试过吗?
rails s -e producation
标签: javascript css ruby-on-rails asset-pipeline