为什么所有文件都包含在Rails的资产管道中? [英] Why are ALL files included in Rails' asset pipeline?

查看:53
本文介绍了为什么所有文件都包含在Rails的资产管道中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么资产管道中包含所有JavaScript和CSS文件,而不是实际使用的文件?

Why are ALL JavaScript and CSS files included in the asset pipeline rather than the ones that are actually being used?

例如,如果我有一个带有主页和博客的简单网站,那么当用户查看博客时,为什么要包含主页的JavaScript和CSS文件?反之亦然,为什么在查看主页时包含博客的资产?

For example, if I have a simple website with a home page and blog, why are the home page's JavaScript and CSS files included when a user is viewing the blog? Or vice versa, why are the blog's assets included when viewing the home page?

推荐答案

它们都被一起编译并缩小了,因此占用的空间很小.

They all get compiled together and minified so the footprint is really small.

一旦它们被加载一次,它们就会被缓存,以便其余页面浏览速度更快.

Also once they are loaded once, they are cached so the rest of the page views are faster.

这篇关于为什么所有文件都包含在Rails的资产管道中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆