1 (function(){ 2 var queue = []; 3 var callback = function(){}; 4 this.mm_load_js = function(path, callbackF, test){ 5 if(callbackF){ 6 callback = callbackF; 7 } 8 $.get(path+'js_includes.xml', function(data, textStatus){ 9 var xml = $(data); 10 $(xml).find('file').each(function(){ 11 queue.push($(this).attr('path')); 12 }); 13 if(test){ 14 $(xml).find('test').each(function(){ 15 queue.push($(this).attr('path')); 16 }); 17 } 18 loaded(); 19 }); 20 } 21 22 function loaded(){ 23 if(queue.length){ 24 var path = queue.shift(); 25 $.getScript(path, loaded); 26 }else{ 27 callback(); 28 } 29 } 30 })()