Skip to content

Instantly share code, notes, and snippets.

@anova
Created December 12, 2012 23:52
Show Gist options
  • Save anova/4272820 to your computer and use it in GitHub Desktop.
Save anova/4272820 to your computer and use it in GitHub Desktop.
Parallel loading for css files. I need this for font embedding css files.
//this script is inline for avoid extra request.
var fonts = new Array();
fonts.push('css/font/pfsquaresanspromedium.css');
fonts.push('css/font/pfhighwaysanspro-thin.css');
fonts.push('css/font/ubuntu-m.css');
fonts.push('css/font/pfhighwaysanspro-regular-light-italic.css');
fonts.push('css/font/pfsquaresanspro-italic-regular.css');
var head = document.getElementsByTagName('head')[0];
var link = document.getElementsByTagName('link')[0];
for(var i in fonts) {
var s = document.createElement('link');
s.rel = 'stylesheet';
s.href = fonts[i];
head.insertBefore(s, link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment