A script to defer loading of non-essential render blocking scripts until after the page fully has loaded complete with CSS.
<script>
document.addEventListener("DOMContentLoaded", theDomHasLoaded, false);
function theDomHasLoaded(e) {
[
// The scripts to be loaded on the page
// DO NOT include scripts that need to be loaded before the dom has fully loaded eg moderniizr.js
'path/to/script.js',
'path/to/another-script.js'
].forEach(function(src) {
var script = document.createElement('script');
script.src = src;
script.async = false;
document.head.appendChild(script);
});
}
</script>