Skip to content

Instantly share code, notes, and snippets.


Jesper Wøldiche woeldiche

View GitHub Profile
scottjehl /
Last active Jul 15, 2020
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with:

For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

woeldiche / template.php
Created Nov 28, 2012
Add classes to fields in egedal theme
View template.php
* Implements template_preprocess_field().
* Adds classes to field based on field name.
* Good options are:
* - Field name: $vars['element']['#field_name'].
* - Content type: $vars['element']['#bundle'].
You can’t perform that action at this time.