Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
load css
(function(doc, type) {
var head = doc.getElementsByTagName('head')[0],
frag = doc.createDocumentFragment(),
add = function(url, id) {
if (doc.getElementById(id)) {return;}
var node = doc.createElement(type);
node.href = url;
id && (node.id = id);
//node.rel = 'stylesheet';
//node.type = 'text/css'
node.setAttribute('rel', 'stylesheet');
node.setAttribute('type', 'text/css');
// firefox chrmoe opera
frag.appendChild(node);
head.appendChild(frag);
// ie
//head.appendChild(node);
};
add('/css/test.css','abc');
}(document, 'link'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment