Created
May 17, 2016 07:05
-
-
Save itsmethemojo/99efd3be13e93a291e958e656cbaf2e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var raf = window.RequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.msRequestAnimationFrame; | |
// defer loading of all app relevant javascript | |
// and non criticial CSS | |
function deferLoad() { | |
// JS | |
var element = document.createElement("script"), | |
l = document.createElement('link'); | |
element.src = "javascript/app.js"; | |
document.body.appendChild(element); | |
// CSS | |
l.rel = 'stylesheet'; | |
l.href = 'css/main.css'; | |
document.getElementsByTagName('head')[0].appendChild(l); | |
} | |
if (raf) { | |
raf(deferLoad); | |
} else if (window.addEventListener) { | |
window.addEventListener("load", deferLoad, false); | |
} else if (window.attachEvent) { | |
window.attachEvent("onload", deferLoad); | |
} else { | |
window.onload = deferLoad; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment