/**
 * Add JS / CSS resource to DOM, if not exists
 * @example loadResource({src:'/my.js',async:true,defer:true}) <br>
 * loadResource("/my.js") or arrays of them 
 * loadResource(["/lol.js","/lol2.js",{src:"/lol2",async:true}])
 * loadResource("/lol.css",{src:"/megalol.css"})
 * USE ONLY ABSOLUTE PATHS
 */
function loadResource(resources){
    var addScriptFn = function(script){
        var resources = document.getElementsByTagName('script'),found=false;
        for(var i=0;i<resources.length;i++){
            var fullSrc = (script.src.indexOf("://") > -1)?script.src:window.location.protocol+"//"+script.src;
            if(resources[i].src===fullSrc){
                found=true;
                break;
            }
        }
        if(!found){
            var domScript = document.createElement('script'); 
            domScript.type = "text/javascript";
            domScript.src = script.src;
            domScript.async = script.async && script.async==true;
            domScript.defer = script.defer && script.defer==true;
            resources[0].parentNode.insertBefore(domScript, resources[0]);
        }
    }, addStyleFn = function(style){
        var link = document.createElement("link");
        link.type = "text/css";
        link.rel = "stylesheet";
        link.href = style.src;
        document.getElementsByTagName("head")[0].appendChild(link);
    }, addElement = function(elem){
        var lastDot = elem.src.lastIndexOf("."), resExt = elem.src.substring(lastDot);
        if(resExt === '.css'){
            addStyleFn(elem);
        }else{
            addScriptFn(elem);
        }
    };
    if(resources instanceof Array){
        for(var i=0;i<resources.length;i++){
            if(typeof resources[i] === 'object' && resources[i].hasOwnProperty("src")){
                addElement(resources[i])
            }else if(typeof resources[i] === 'string'){
                addElement({src:resources[i]});
            }else{
                console.log("Resource #"+i+" is invalid!");
            }
        }
    }else{
        if(typeof resources === 'object' && resources.hasOwnProperty("src")){
            addElement(resources);
        }else if(typeof resources === 'string'){
            addElement({src:resources});
        }else{
            console.log("Resource is invalid!");
        }
    }
}
@@ -11,14 +11,8 @@
  JS 
-/ CSS 
 reso
@@ -50,24 +50,26 @@
 example load
+Js
 Resource(%7Bsr
@@ -107,20 +107,17 @@
 e%7D) 
-%3Cbr%3E%0A *
+or
  load
+Js
 Reso
@@ -149,32 +149,34 @@
 of them %0A * load
+Js
 Resource(%5B%22/lol.
@@ -221,57 +221,8 @@
 %7D%5D)%0A
- * loadResource(%22/lol.css%22,%7Bsrc:%22/megalol.css%22%7D)%0A
  * U
@@ -270,24 +270,22 @@
 esource(
-resource
+script
 s)%7B%0A    
@@ -332,24 +332,22 @@
     var 
-resource
+script
 s = docu
@@ -413,32 +413,30 @@
 r(var i=0;i%3C
-resource
+script
 s.length;i++
@@ -565,24 +565,22 @@
      if(
-resource
+script
 s%5Bi%5D.src
@@ -982,24 +982,22 @@
         
-resource
+script
 s%5B0%5D.par
@@ -1032,547 +1032,51 @@
 pt, 
-resources%5B0%5D);%0A        %7D%0A    %7D, addStyleFn = function(style)%7B%0A        var link = document.createElement(%22link%22);%0A        link.type = %22text/css%22;%0A        link.rel = %22stylesheet%22;%0A        link.href = style.src;%0A        document.getElementsByTagName(%22head%22)%5B0%5D.appendChild(link);%0A    %7D, addElement = function(elem)%7B%0A        var lastDot = elem.src.lastIndexOf(%22.%22), resExt = elem.src.substring(lastDot);%0A        if(resExt === '.css')%7B%0A            addStyleFn(elem);%0A        %7Delse%7B%0A            addScriptFn(elem);%0A        %7D%0A    %7D;%0A    if(resource
+scripts%5B0%5D);%0A        %7D%0A    %7D;%0A    if(script
 s in
@@ -1114,24 +1114,22 @@
 r i=0;i%3C
-resource
+script
 s.length
@@ -1153,32 +1153,30 @@
   if(typeof 
-resource
+script
 s%5Bi%5D === 'ob
@@ -1184,24 +1184,22 @@
 ect' && 
-resource
+script
 s%5Bi%5D.has
@@ -1242,29 +1242,29 @@
  add
-Element(resource
+ScriptFn(script
 s%5Bi%5D)
+;
 %0A   
@@ -1288,24 +1288,22 @@
 (typeof 
-resource
+script
 s%5Bi%5D ===
@@ -1333,37 +1333,36 @@
      add
-Element(%7Bsrc:resource
+ScriptFn(%7Bsrc:script
 s%5Bi%5D%7D);%0A
@@ -1401,32 +1401,35 @@
    console.log(%22
+JS 
 Resource #%22+i+%22 
@@ -1492,32 +1492,30 @@
   if(typeof 
-resource
+script
 s === 'objec
@@ -1520,24 +1520,22 @@
 ect' && 
-resource
+script
 s.hasOwn
@@ -1571,24 +1571,23 @@
  add
-Element(resource
+ScriptFn(script
 s);%0A
@@ -1610,24 +1610,22 @@
 (typeof 
-resource
+script
 s === 's
@@ -1652,29 +1652,28 @@
  add
-Element(%7Bsrc:resource
+ScriptFn(%7Bsrc:script
 s%7D);
@@ -1713,16 +1713,19 @@
 le.log(%22
+JS 
 Resource

Add ability to load resources async and update bs-js, add configurable mail from.