简体   繁体   English

Renderblock JS和CSS问题-W3 Total cache插件

[英]Renderblock JS and CSS Issue - W3 Total cache plugin

I'm using W3 Total Cache plugin on WP 4.3.1 for minifying Js and CSS for "above the fold" pagespeed requirements. 我正在使用WP 4.3.1上的W3 Total Cache插件来减少Js和CSS的“超越折叠”页面速度要求。

I managed to minify most of the stuff without a problem, this is what's left - 我设法无问题地缩小了大部分内容,剩下的就是-

jquery.js > can be minfied in async after <body> , otherwise it breaks the site, if minified this way pagespeed generates another file named default.include-body.8853b0.js which can be minified but does not dissapear in pagespeed. 可以在<body>之后以异步方式最小化jquery.js >,否则会破坏站点,如果以这种方式缩小,pagespeed会生成另一个名为default.include-body.8853b0.js的文件,该文件可以缩小但不会在pagespeed中消失。

CSS 的CSS

js_composer.css
bootstrap.min.css
revolution-styles.css
style.css
vivaco-animations.css

These can be mnified, but get the layout messed up in one way or another. 这些可以简化,但是会以一种或另一种方式弄乱布局。

What's the best way to minify the rest? 减少其余部分的最佳方法是什么?

Minifying files is best using task runner such as gruntjs. 最好使用任务运行程序(例如gruntjs)来缩小文件。 You can pick what you want to minify in order. 您可以按顺序选择要缩小的内容。

You can learn more about gruntjs here: http://gruntjs.com/plugins 您可以在此处了解有关gruntjs的更多信息: http ://gruntjs.com/plugins

Google Pagespeed returns minified css and js when you analyze your website, you will find a download link at the bottom of the page. 当您分析网站时,Google Pagespeed返回最小的CSS和JS,您将在页面底部找到一个下载链接。 This works well for me as my pages still remain the same after optimization. 这对我来说效果很好,因为优化后我的页面仍然保持不变。 https://developers.google.com/speed/pagespeed/insights/?url=your_web_url_here https://developers.google.com/speed/pagespeed/insights/?url=your_web_url_here

OK, so the jquery.js has to be set to defer, asyncing it does not work. 好的,因此必须将jquery.js设置为推迟,使其不起作用。

I did that with this plugin https://wordpress.org/plugins/async-javascript/ 我使用这个插件https://wordpress.org/plugins/async-javascript/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM