php - 如何修复“消除 Magento 首屏内容中的渲染阻塞 JavaScript 和 CSS

标签 php apache magento optimization

我缩小了 js 和 css 并优化了图像。使用 async="async"在 js适用的地方。如何修复“消除渲染阻塞 首屏内容中的 JavaScript 和 CSS”

有什么想法吗?

最佳答案

Render means loading, so if something is render-blocking, it means that it is keeping the page from loading as quickly as it could.

1) load css in the headers but Js in the footer

2) Use sprite images

3) You can add htaccess code for for better performance

  • Gzip compression
  • set Expires and Cache-Control headers
  • Browser cache-control

4) Load only required css/js on pages

Choose Best Method Once you’ve identified which scripts need to be moved it is time to decide “how” to fix them. There are two main methods to choose from. The first is to make the scripts inlined; in this method the contents of the script are added directly into the HTML of the page and are only loaded once they are needed. This is the best option if the script is small and applies to a single page.

Another option is to defer the script. When you defer JavaScript you are delaying any non-essential scripts from loading until after the first render or until after the more essential portions have loaded. This method is best when the script is not crucial and can wait to load.

PS:- We can not resolve this fully in some cases.

I Hope it's helpful for you

关于php - 如何修复“消除 Magento 首屏内容中的渲染阻塞 JavaScript 和 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45372106/

相关文章:

php - for循环中的Mysql查询不插入所有值

php - 谷歌地图突然不再工作了

apache - .htaccess 将 http 重定向到 https

python - 值错误 : signal only works in main thread - Django - mod_wsgi

Magento 1.7 - 以编程方式设置客户组价格

magento - magento 中特定客户群的折扣

php - Laravel - 将值从路由器传递到 Controller

php - 防止 cURL 引荐来源欺骗

apache - 使用 htaccess RewriteRule 复制站点

php - 扩展布局 .xml 文件在与父主题不同的 <vendor> 子主题中不起作用 : Magento 2. 0.4