简体   繁体   English

如何推迟Rails应用程序中未使用的javascript文件,以使应用程序运行更快

[英]How can i defer javascript files not in use in my rails app to make the app run faster

Using Google PageSpeed extension for my rails app 在我的Rails应用程序中使用Google PageSpeed扩展程序

It gave me a suggestion that leads to my question. 它给了我一个建议,导致了我的疑问。 Here was the suggestion 这是建议
181.6KiB of JavaScript is parsed during initial page load. 在初始页面加载期间会解析181.6KiB的JavaScript。 Defer parsing JavaScript to reduce blocking of page rendering. 延迟解析JavaScript以减少页面呈现的阻塞。

Other problems were that my css,js and html seem not to be minified my files were kept in the assets directory.. 其他问题是我的css,js和html似乎没有缩小,我的文件保存在资产目录中。

Don't worry about the JS stuff. 不用担心JS的东西。 If you run a pagespeed on google.com it will say that too (as a low priority). 如果您在google.com上运行Pagespeed,它也会说(低优先级)。 Not everything pagespeed tells you is meant to be done. 并非pagespeed告诉您的一切都是注定要完成的。 Even if you did defer your JS, a lot of stuff might break due to it needing to run on page load. 即使您推迟了JS,由于需要在页面加载时运行,很多内容也可能会中断。

Now for the css, js, and html, it is most likely not minified because you are running in development mode (which disables that). 现在,对于css,js和html,由于您正在开发模式下运行(禁用了该模式),因此很有可能没有缩小代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在Rails应用程序中使基础全局变量可用于我的所有scss文件 - How can i make foundation global variables available to all my scss files in a rails app 如何使规格运行得更快? - How can I make my specs run faster? 如何在 Rails 应用程序的 Digitalocean Space 中添加文件的下载链接? - How can I add a download link to files in my Digitalocean Space in my Rails app? 如何让我的导航栏出现在我的 rails 应用程序的每个页面上? - How can I make my navbar appear on every page in my rails app? 如何使Rails应用程序仅在子域上运行? - How to I make a rails app run just on a subdomain? 如何防止缓存/ Cookie影响生产Rails应用程序中ckeditor javascript文件的路径? - How can I prevent cache/cookies from affecting the path of ckeditor javascript files in a production rails app? 如何获得我的Rails应用程序以使用〜/ .bashrc保存的ENV VARS? - How can i get my Rails app to use my ~/.bashrc saved ENV VARS? 我可以在Rails应用程序的名称中使用数字吗? - Can I use numbers in the name of my Rails app? 在Rails应用中,如何使用按钮来运行非静态控制器方法? 没有路线错误 - In a Rails app, how can I use a button to run a non-restful controller method? Getting no routes error 如何运行Rails应用程序的多个实例? - How do I run multiple instances of my Rails app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM