This code allows you to use style
tag with src
attribute, just like script
.
Merely for fun. Don't use it on production, because browser could not cache and load styles asynchronously.
(function() {
var styleTags = document.querySelectorAll('style');
for (var i = 0, l = styleTags.length; i < l; ++i) {
(function(el){
var src = el.getAttribute('src');
if(src.length > 0) {
var oReq = new XMLHttpRequest();
oReq.onload = (function(){
return function() {
el.innerText = this.responseText;
}
})();
oReq.open("get", src, true);
oReq.send();
}
})(styleTags[i]);
}
})();