question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use non-blocking CSS

See original GitHub issue

Currently 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:

  1. 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.
  2. Make the rest of the links be non-blocking by using something like loadCSS.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
DesignByOnyxcommented, Aug 30, 2016

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.

1reaction
frank-dspeedcommented, Oct 3, 2016

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found