How to load CSS (fast)
calendar.perfplanet.com·9h
🖥️Server-Side Rendering
Preview
Report Post

Loading styles on the web is something that looks trivial at first. You just add a <link rel=stylesheet> to your page (or <style> for inline styles) and you’re done.

But if you wanted to load CSS fast, all of the sudden you run into trouble…

Assuming you have a traditional web app (or what the kids call Multi-Page App/MPA), you now need to make tradeoffs:

  • You most probably want the CSS that’s critical to the page the user is loading to block the rendering of that page, to avoid FOUC.
  • At the same time, you don’t want to load all the styles any page on your site may need, as that would delay that critical first load (and your FCP and LCP metrics on that page).
  • But, if you were to only load the critical CSS …

Similar Posts

Loading similar posts...