mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-28 18:23:35 +00:00
Improved download speed of js and css files
This commit is contained in:
parent
749bf4416d
commit
1e019376d2
8 changed files with 124 additions and 29 deletions
|
|
@ -269,6 +269,50 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* improve callback of funcs so
|
||||
* we pop number of function and
|
||||
* if it's last we call pCallBack
|
||||
*
|
||||
* @param pParams_a
|
||||
* @param pFunc - onload function
|
||||
*/
|
||||
DOM.anyLoadInParallel = function(pParams_a, pFunc){
|
||||
var lRet = Util.isArray(pParams_a),
|
||||
done = [],
|
||||
|
||||
doneFunc = function (pCallBack){
|
||||
Util.exec(pCallBack);
|
||||
|
||||
if( !done.pop() )
|
||||
Util.exec(pFunc);
|
||||
};
|
||||
|
||||
if(!lRet){
|
||||
pParams_a = [pParams_a];
|
||||
}
|
||||
|
||||
for(var i = 0, n = pParams_a.length; i < n; i++){
|
||||
var lParam = pParams_a.pop();
|
||||
|
||||
if(lParam){
|
||||
done.push(i);
|
||||
|
||||
if(Util.isString(lParam) )
|
||||
lParam = { src : lParam };
|
||||
|
||||
var lFunc = lParam.func;
|
||||
lParam.func = Util.retExec(doneFunc, lFunc);
|
||||
|
||||
DOM.anyload(lParam);
|
||||
|
||||
lRet = true;
|
||||
}
|
||||
}
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
/**
|
||||
* Функция создаёт элемент и загружает файл с src.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -85,18 +85,20 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror;
|
|||
console.time('codemirror load');
|
||||
var lDir = cloudcmd.LIBDIRCLIENT + 'editor/codemirror/';
|
||||
|
||||
DOM.anyLoadOnLoad([
|
||||
lDir + 'codemirror.css',
|
||||
lDir + 'theme/night.css',
|
||||
lDir + 'mode/javascript.js',
|
||||
lDir + 'codemirror.js'],
|
||||
|
||||
function(){
|
||||
console.timeEnd('codemirror load');
|
||||
CodeMirrorLoaded = true;
|
||||
Util.exec(pCallBack);
|
||||
}
|
||||
);
|
||||
DOM.jsload(lDir + 'codemirror.js', function(){
|
||||
DOM.anyLoadInParallel([
|
||||
lDir + 'codemirror.css',
|
||||
lDir + 'theme/night.css',
|
||||
lDir + 'mode/javascript.js',
|
||||
],
|
||||
|
||||
function(){
|
||||
console.timeEnd('codemirror load');
|
||||
CodeMirrorLoaded = true;
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ var CloudCommander, Util, DOM, CloudFunc, $;
|
|||
*/
|
||||
function load(pCallBack){
|
||||
console.time('menu load');
|
||||
|
||||
|
||||
var lDir = Menu.dir;
|
||||
|
||||
DOM.anyLoadOnLoad([
|
||||
DOM.anyLoadInParallel([
|
||||
lDir + 'contextMenu.js',
|
||||
lDir + 'contextMenu.css'],
|
||||
function(){
|
||||
|
|
|
|||
|
|
@ -29,16 +29,17 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
console.time('github load');
|
||||
|
||||
var lDir = './lib/client/storage/github/';
|
||||
DOM.anyLoadOnLoad([
|
||||
lDir + 'github.js',
|
||||
lDir + 'lib/base64.js',
|
||||
lDir + 'lib/underscore.js'],
|
||||
|
||||
function(){
|
||||
console.timeEnd('github load');
|
||||
DOM.Images.hideLoad();
|
||||
DOM.jsload(lDir + 'github.js', function(){
|
||||
DOM.anyLoadOnLoad([
|
||||
lDir + 'lib/base64.js',
|
||||
lDir + 'lib/underscore.js'],
|
||||
|
||||
Util.exec(pCallBack);
|
||||
function(){
|
||||
console.timeEnd('github load');
|
||||
DOM.Images.hideLoad();
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ var CloudCommander, Util, DOM, $;
|
|||
console.time('terminal load');
|
||||
|
||||
var lDir = 'lib/client/terminal/jquery-terminal/jquery.';
|
||||
DOM.cssLoad(lDir + 'terminal.css');
|
||||
|
||||
DOM.anyLoadOnLoad([
|
||||
DOM.anyLoadInParallel([
|
||||
lDir + 'terminal.js',
|
||||
lDir + 'mousewheel.js'],
|
||||
lDir + 'mousewheel.js',
|
||||
lDir + 'terminal.css'],
|
||||
|
||||
function(){
|
||||
console.timeEnd('terminal load');
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ var CloudCommander, Util, DOM, CloudFunc, $;
|
|||
console.time('fancybox load');
|
||||
var lDir = cloudcmd.LIBDIRCLIENT + 'viewer/fancybox/';
|
||||
|
||||
DOM.anyLoadOnLoad([
|
||||
|
||||
DOM.anyLoadInParallel([
|
||||
lDir + 'jquery.fancybox.css',
|
||||
lDir + 'jquery.fancybox.js'],
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue