Use non-blocking CSS
See original GitHub issueCurrently donejs does something which goes against PageSpeed recommendations and inserts all of the css into the head as <link>
s. This will block the page from rendering as these stylesheets are loaded.
We should change this and do a couple of things:
- Inline “essential” styles directly in
<style>
tags. This might just be the main css bundle. Ideally this could even be trimmed down to just selectors that are being used by the page. - Make the rest of the links be non-blocking by using something like loadCSS.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Defer non-critical CSS - web.dev
Web pages that contain unnecessarily large styles take longer to render. In this guide, you'll learn how to defer non-critical CSS with the ......
Read more >Loading CSS without blocking render
Another way to defer loading of CSS is just to put it at the bottom of the document, like we often do with...
Read more >Loading CSS without blocking render - Keith Clark
This article demonstrates a technique to get content in front of visitors as quickly as possible by asynchronously downloading stylesheets ...
Read more >Non blocking CSS load on the page - Dejan Stojanovic
Load external CSS files in an async manner. Like JavaScript, CSS files are also loaded on the page by default in a blocking...
Read more >Load CSS Asynchronously & Remove Render-blocking CSS
The “media” attribute is used to upload CSS files asynchronously within the HTML Document. The media attribute specifies which media types the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have a lot of experience doing this and getting a good rapport with PageSpeed is very difficult. Inlining critical CSS and deferring other CSS is really the only way. Pretty much anything that requires an http request before the DOMContentLoaded event fires (CSS
<link>
s and synchronous<script>
tags) will cost you favor with PageSpeed. It basically wants your initial HTML payload to deliver everything required to render something for the user without waiting on extra requests.i think its realy a good idea to add loadCSS Functionality but we should add a wrapper around it that accepts config like inline defer for each css that it loads also the wrapper should be pushstate agnostic so that it still allows reaching inlined and not inlined css files