Skip to content

Instantly share code, notes, and snippets.

@nicbell
Created May 31, 2016 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicbell/9a9c919e6d69aff47e285945550b445c to your computer and use it in GitHub Desktop.
Save nicbell/9a9c919e6d69aff47e285945550b445c to your computer and use it in GitHub Desktop.
var win = window, doc = win.document, docElem = doc.documentElement;
// Replace 'no-js'/'js' class on <html>
docElem.className = docElem.className.replace(/\bno-js\b/g, '') + ' js ';
// loadJS: load a JS file asynchronously. From https://github.com/filamentgroup/loadJS/
function loadJS(e,t){"use strict";var n=doc.getElementsByTagName("script")[0],o=doc.createElement("script");return o.src=e,o.async=!0,n.parentNode.insertBefore(o,n),t&&"function"==typeof t&&(o.onload=t),o}
win.loadJS = loadJS;
// Enhancements for qualified browsers - "Cutting the Mustard"
if( !('addEventListener' in win && 'classList' in docElem) ){
// Load shims for browsers that don't pass the test
loadJS('your-own-script.js');
// Add your own enhancements here, see https://github.com/filamentgroup/enhance for more info
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment