-
Notifications
You must be signed in to change notification settings - Fork 0
/
magritte.js
42 lines (27 loc) · 1.08 KB
/
magritte.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* magritte 2012
* author: Mariz Melo
* license: MIT
*/
(function($){
$.fn.magritte = function(mgname, mgsrc, mgtype){
var lazyJS = function(scriptSRC){
}//lazyJS()
var lazyCSS = function(scriptSRC){
}//lazyCSS()
var lazyPLUG = function(pluginNAME, pluginSRC){
}//lazyPLUG
}//fn.magritte()
})(jQuery);
//LAZY LOAD JAVASCRIPT SCRIPT FILES
function lazyJS(pluginNAME, pluginSRC, CACHE){
var pluginPATH; //hold the path for the plugin/script
pluginSRC? pluginPATH = pluginSRC.substr(0,(pluginSRC.length)-3) : pluginPATH = "./lib/js/"+pluginNAME; //builds correct path for the plugin/script file
CACHE?1:0; //if the script should be cached or not
//verifies if the plugin do not exist, if true loads the plugin
if(!jQuery().pluginNAME){
var insertScript = document.createElement('script');
insertScript.setAttribute('src',pluginPATH+".js"); //set the path (defined above) for the script
insertScript.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(insertScript);
}//end:if
}//end:lazyJS()