Created
October 21, 2016 11:13
-
-
Save shinmai/97c9b24a429cbff55e8698b3a078f85f to your computer and use it in GitHub Desktop.
jquery-style queryselector shortcut at $ and a most barebones script loader
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
if(!$)var $=a=>{let r=document.querySelectorAll(a);return r.length>1?r:r[0]} // $('.class > div#heading') etc. returns an array if more than one match is found | |
((l,Z)=>{var d=(a)=>{return new Promise((c,d)=>{var b=document.createElement("script");b.onload=c,b.onerror=d,b.async=1,b.src=a,document.head.appendChild(b)})};Promise.all(l.split(",").map(a=>{return d('lib/'+a+'.js')})).then(Z)})( | |
'api,auth,../main', // loads lib/api.js, lib/auth.js & main.js. if your file layout is differnet, edit the call to d() at 2:201 | |
X=>{console.log('scripts loaded')} // callback function to run when scripts have loaded | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment