Skip to content

Instantly share code, notes, and snippets.

@hdragomir
hdragomir / sm-annotated.html
Last active October 9, 2024 00:35
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@csswizardry
csswizardry / email.md
Last active September 5, 2018 14:31
I frequently get asked about over-abstracted CSS, and ‘can CSS be too modular’, so I thought I’d publish this anonymised email I received, along with my reply.
@johngerome
johngerome / cache-fonts.js
Created February 13, 2017 02:10
non-blocking fonts by caching it.
// to encode a font into Base64 use this tool https://www.npmjs.com/package/font-store
(function (window, document) {
'use strict';
var isModernBrowser = (
'querySelector' in document &&
'localStorage' in window &&
'addEventListener' in window
),
key = 'font',