Skip to content

Instantly share code, notes, and snippets.

@eneko
Created January 27, 2010 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eneko/288091 to your computer and use it in GitHub Desktop.
Save eneko/288091 to your computer and use it in GitHub Desktop.
// Add callback support to Asset.css for all browsers
Asset.css = function(source, onLoad) {
var link = new Element('link', { rel: 'stylesheet', media: 'screen', type: 'text/css', href: source });
if (("onload" in link) && !Browser.Engines.webkit()) {
if (onLoad) link.onload = onLoad;
} else {
(function() {
try {
link.sheet.cssRules;
} catch (e) {
setTimeout(arguments.callee, 100);
return;
};
if (onLoad) onLoad();
})();
}
link.inject(document.head);
return link;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment