I have loaded a stylesheet with AJAX, the file is stored in the data variable. Now I need to access it's rules (there's a functionality behind it). The solution I am using now is this:
stylesheet = document.createElement('style');
stylesheet.type = 'text/css';
stylesheet.innerHTML = data;
document.head.appendChild(stylesheet);
stylesheet = document.styleSheets[2]; // I know which one is my file
rules = stylesheet.rules || stylesheet.cssRules;
Now the problem is that when it is added to the head, styling is applied on the page. How do I do the same without adding to the head?
Tried various things with Object.create(CSSStyleSheet.prototype) but couldn't get it done...