Skip to content

Instantly share code, notes, and snippets.

@13twelve
Created January 22, 2016 15:44
Show Gist options
  • Save 13twelve/9a28a8dfc3da2f27aa71 to your computer and use it in GitHub Desktop.
Save 13twelve/9a28a8dfc3da2f27aa71 to your computer and use it in GitHub Desktop.
head.js
/* to be included compressed, inline, in the head of the document */
var A17 = window.A17 || {};
A17.svgSupport = document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1");
A17.browserSpec = (typeof document.querySelectorAll && 'addEventListener' in window && A17.svgSupport) ? "html5" : "html4";
A17.touch = (('ontouchstart' in window) || window.documentTouch && document instanceof DocumentTouch) ? true : false;
A17.loadCSS = function(doc,href,before,media){
"use strict";
var ss = doc.createElement("link");
var ref;
if(before){
ref = before;
} else if( doc.querySelectorAll ){
var refs = doc.querySelectorAll("style,link[rel=stylesheet],script");
ref = refs[ refs.length - 1];
} else {
ref = doc.getElementsByTagName("script")[ 0 ];
}
var sheets = doc.styleSheets;
ss.rel = "stylesheet";
ss.href = href;
ss.media = "only x";
ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
ss.onloadcssdefined = function( cb ){
var defined;
for( var i = 0; i < sheets.length; i++ ){
if( sheets[ i ].href && sheets[ i ].href === ss.href ){
defined = true;
}
}
if( defined ){
cb();
} else {
setTimeout(function() {
ss.onloadcssdefined( cb );
});
}
};
ss.onloadcssdefined(function() {
ss.media = media || "all";
});
return ss;
};
(function(d) {
var de = d.documentElement,
loadBefore = d.getElementById("icons_ss");
de.className = de.className.replace(/\bno-js\b/," js "+A17.browserSpec+(A17.touch ? " touch" : " no-touch")+(A17.svgSupport ? " svg" : " no-svg")+(('objectFit' in de.style) ? " objectFit" : " no-objectFit"));
A17.loadCSS(d,"/stylesheets/icons.css",loadBefore);
})(document);
var A17=window.A17||{};A17.svgSupport=document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"),A17.browserSpec="addEventListener"in window&&A17.svgSupport?"html5":"html4",A17.touch="ontouchstart"in window||window.documentTouch&&document instanceof DocumentTouch?!0:!1,A17.loadCSS=function(doc,href,before,media){"use strict";var ref,ss=doc.createElement("link");if(before)ref=before;else if(doc.querySelectorAll){var refs=doc.querySelectorAll("style,link[rel=stylesheet],script");ref=refs[refs.length-1]}else ref=doc.getElementsByTagName("script")[0];var sheets=doc.styleSheets;return ss.rel="stylesheet",ss.href=href,ss.media="only x",ref.parentNode.insertBefore(ss,before?ref:ref.nextSibling),ss.onloadcssdefined=function(cb){for(var defined,i=0;i<sheets.length;i++)sheets[i].href&&sheets[i].href===ss.href&&(defined=!0);defined?cb():setTimeout(function(){ss.onloadcssdefined(cb)})},ss.onloadcssdefined(function(){ss.media=media||"all"}),ss},function(d){var de=d.documentElement,loadBefore=d.getElementById("icons_ss");de.className=de.className.replace(/\bno-js\b/," js "+A17.browserSpec+(A17.touch?" touch":" no-touch")+(A17.svgSupport?" svg":" no-svg")+("objectFit"in de.style?" objectFit":" no-objectFit")),A17.loadCSS(d,"/stylesheets/icons.css",loadBefore)}(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment