Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Combined Loading of included JS
26/09/2008
10:02
Avatar
dasher
New Member
Members
Forum Posts: 1
Member Since:
26/09/2008
sp_UserOfflineSmall Offline

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();

29/09/2008
09:23
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

01/10/2008
04:09
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

24/04/2009
03:16
Avatar
jeff
Member
Members
Forum Posts: 5
Member Since:
16/04/2009
sp_UserOfflineSmall Offline

Hi,

I would like to use this combinedIntoOne feature, but there is no combine.php file with the jqGrid code. Where can I get the combine.php file?

I am using jqGrid 3.4.3.

Thanks!
--jeff

25/04/2009
05:21
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information