简体   繁体   English

Bootstrap,消除渲染阻塞资源

[英]Bootstrap, Eliminate render-blocking resources

Resources are blocking the first paint of your page.资源阻止了页面的第一次绘制。 Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles考虑内联交付关键的 JS/CSS 并推迟所有非关键的 JS/样式

css/bootsrtap.min.css css/main.css css/bootsrtap.min.css css/main.css

I am getting this message while checking my website loading speed on GTmetrix, PageSpeed Insights.我在 GTmetrix、PageSpeed Insights 上检查我的网站加载速度时收到此消息。 It is slowing my website down.它正在减慢我的网站速度。 How can I solve this issue?我该如何解决这个问题? Please help, Thank you.请帮助,谢谢。

Deliver critical CSS by extracting the class definitions and put those classes inside a <style> block at the head of the page:通过提取 class 定义来提供关键的 CSS,并将这些类放在页面头部的<style>块中:

eg例如

<style type="text/css">
.accordion-btn {background-color: #ADD8E6;color: #444;cursor: pointer;padding: 18px;width: 100%;border: none;text-align: left;outline: none;font-size: 15px;transition: 0.4s;}.container {padding: 0 18px;display: none;background-color: white;overflow: hidden;}
</style>

Deferring all non-critical CSS.推迟所有非关键 CSS。

eg例如

<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="styles.css"></noscript>

For more details, refer to this guide: https://web.dev/defer-non-critical-css/有关详细信息,请参阅本指南: https://web.dev/defer-non-critical-css/

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

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