Skip to content

Instantly share code, notes, and snippets.

View woeldiche's full-sized avatar

Jesper Wøldiche woeldiche

  • Clearhaus A/S & Unzer
  • Aarhus, Denmark
  • X @woeldiche
View GitHub Profile
@woeldiche
woeldiche / template.php
Created November 28, 2012 10:23
Add classes to fields in egedal theme
<?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'].
@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
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: https://github.com/filamentgroup/loadCSS/


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: https://gist.github.com/igrigorik/2935269#file-notes-md ).

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