UNPKG

473 BJavaScriptView Raw
1export function insertCSS(name, css) {
2 if (document.querySelector('[data-css-file="' + name + '"]')) {
3 return;
4 }
5
6 var head = document.head || document.getElementsByTagName('head')[0],
7 style = document.createElement('style');
8 style.setAttribute('data-css-file', name);
9
10 style.type = 'text/css';
11 if (style.styleSheet) {
12 style.styleSheet.cssText = css;
13 } else {
14 style.appendChild(document.createTextNode(css));
15 }
16
17 head.appendChild(style);
18}
\No newline at end of file