Forum
10:02
26/09/2008
Hi,
I needed to combine loading of the included JS into a single request to reduce load time & requests against our environment.
Atteched is a unified diff of the changes to jquery.jqGrid.js:
function jqGridInclude()
{
- var pathtojsfiles = "/java/js/"; // need to be ajusted
+ var pathtojsfiles = "js/"; // need to be ajusted
// if you do not want some module to be included
// set include to false.
// by default all modules are included.
var minver = true;
+ var combineIntoOne = true;
+ var combinedInclude = new Array();
+ var combinedIncludeURL = "/static/combine.php?type=javascript&files=";
+
var modules = [
{ include: true, incfile:'grid.base.js',minfile: 'min/grid.base-min.js'}, // jqGrid base
{ include: true, incfile:'grid.formedit.js',minfile: 'min/grid.formedit-min.js' }, // jqGrid Form editing
@@ -14,13 +18,27 @@
{ include: true, incfile:'grid.custom.js',minfile: 'min/grid.custom-min.js'}, //jqGrid custom
{ include: true, incfile:'grid.postext.js',minfile: 'min/grid.postext-min.js'} //jqGrid postext
];
- for(var i=0;i<modules.length; i++)
- {
+ for(var i=0;i<modules.length; i++) {
+ var filename = "";
if(modules[i].include === true) {
- if (minver !== true) IncludeJavaScript(pathtojsfiles+modules[i].incfile,CallMe);
- else IncludeJavaScript(pathtojsfiles+modules[i].minfile,CallMe);
+ if (minver !== true) {
+ filename = pathtojsfiles+modules[i].incfile;
+ } else {
+ filename = pathtojsfiles+modules[i].minfile;
+ }
+ if (combineIntoOne !== true) {
+ IncludeJavaScript(pathtojsfiles+modules[i].incfile,CallMe);
+ } else {
+ combinedInclude[combinedInclude.length] = filename;
+ }
}
}
+
+ if ((combineIntoOne === true) && (combinedInclude.length>0) ) {
+ var fileList = implode(",",combinedInclude);
+ IncludeJavaScript(combinedIncludeURL+fileList,CallMe);
+ }
+
function CallMe() {
return true;
}
@@ -41,6 +59,15 @@
};
return false;
}
+ function implode( glue, pieces ) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: _argos
+ // * example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
+ // * returns 1: 'Kevin van Zonneveld'
+
+ return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces );
+ }
}
jqGridInclude();
09:23
Moderators
30/10/2007
Hello,
Thank you very much for this. I will make some tests and if possible will include this in the upcomming release.
Thank you
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
04:09
Moderators
30/10/2007
Hello,
I have make some tests and it seems that this work like a charm.
The loading of the script is more that 10 time faster.
Of course there are some limitations.
- IE does not support gzip, but instead of this the speed is impressed.
- This can be used only in PHP
- We should have a combine script
Instead of this I will include this in the upcomming release again with the
combine.php script.
Thanks
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
05:21
Moderators
30/10/2007
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
49 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66