Created
November 21, 2016 14:07
-
-
Save milosdjakonovic/c4e7561d8e7aa166411f6ad101e589cf to your computer and use it in GitHub Desktop.
Requirejs with localstorage caching
This file contains hidden or 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(w,d){ | |
var DATA_MAIN='assets/js/login'; | |
sc = d.createElement('script'), head = d.getElementsByTagName('head')[0]; | |
sc.setAttribute('data-main', DATA_MAIN ); | |
sc.setAttribute('async', 'true'); | |
if( !'localStorage' in w || !w.localStorage.getItem('requirejs')){ | |
sc.src="assets/js/require.min.js" | |
} else { | |
sc.innerHTML=localStorage.getItem('requirejs'); | |
} | |
head.appendChild(sc); | |
}(window,document)); |
This file contains hidden or 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
// need to set `s` variable to point to right target file | |
!function(e,t){var s="assets/js/login";sc=t.createElement("script"),head=t.getElementsByTagName("head")[0],sc.setAttribute("data-main",s),sc.setAttribute("async","true"),!1 in e||!e.localStorage.getItem("requirejs")?sc.src="assets/js/require.min.js":sc.innerHTML=localStorage.getItem("requirejs"),head.appendChild(sc)}(window,document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment