We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • It’s a snippet, named getChunks. The MODx class function (method?) getChunk only returns one chunk at a time. This snippet gets all of the chunks belonging to a given category (or array of categories). I can see where this could be very useful.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 28218
      • 48 Posts
      Anyone took a chance at trying to use this combine script: http://rakaz.nl/code/combine

      "The idea is that you have one directory for css files and one directory for javascript files on your server. If you rewrite the URLs that point to these directories to a small script that intercepts the requests for those files. The script loads the file from disk and compresses it using gzip. It then sends that compressed file back to the browser. Given that javascript and css files compress really well this will greatly decrease the size of the data that is going to be transferred and thus decrease the time needed to download these files. Because this works completely transparently you do not need to change anything in your existing code."
        • 28218
        • 48 Posts
        Quote from: lossendae at Dec 02, 2009, 09:18 AM

        I don’t use minify but i do compress the js by putting an index.php file in my template directory which regroup all the needed libs and gzip them.

        Then in my template i load it automatically

        //Loading the index file in my template directory
        <script type="text/javascript" src="[(base_url)]/assets/templates/mytemplates/libs/"></script>
        


        I’m using ExtJS on front end and it reduce the size from 685kb to 135kb. If someone is interested, here a sample code:

        <?php
        ob_start ("ob_gzhandler");
        header("Content-type: text/javascript; charset: UTF-8");
        header("Cache-Control: must-revalidate");
        $offset = 60 * 60 ; // Duration in seconds before the cache expires
        $ExpStr = "Expires: " .
        gmdate("D, d M Y H:i:s",
        time() + $offset) . " GMT";
        header($ExpStr);
        
        // Javascript files to compress
        include $_SERVER['DOCUMENT_ROOT'].'/assets/libs/extjs/adapter/ext/ext-base.js';
        include $_SERVER['DOCUMENT_ROOT'].'/assets/libs/extjs/ext-all.js';
        


        Now i don’t know if it’s possible to use this method in combination with MODx function getRegisteredClientScripts(), it could be useful.





        Thanks!!

        I have used your method for combining multiple js files to one. Modified the request for css to!
        I hope the MODX caching is advance enough to cache these files
          • 5340
          • 1,624 Posts
          I do not think the above is related to modx caching. More like instruction for the browser.

          I might be wrong.
            • 5340
            • 1,624 Posts
              • 28218
              • 48 Posts
              Just implemented Smart optimizer http://farhadi.ir/works/smartoptimizer
              Works great, works with Modx.
                • 28868
                • 1 Posts
                Web Optimizer - http://www.web-optimizer.us/ - has a lot of auto optimization techniques. Very powerfull package.
                Also it supports modx.
                  • 28218
                  • 48 Posts
                  Quote from: sunnybear at Dec 19, 2009, 10:01 PM

                  Web Optimizer - http://www.web-optimizer.us/ - has a lot of auto optimization techniques. Very powerfull package.
                  Also it supports modx.

                  Works great, one big ooops....
                  Note: Web Optimizer Community Edition can’t be used on commercial websites. For such websites you need to purchase Lite Edition or Premium Edition.
                    • 10194
                    • 16 Posts
                    Quote from: spoetnik at Dec 16, 2009, 08:22 PM

                    Just implemented Smart optimizer http://farhadi.ir/works/smartoptimizer
                    Works great, works with Modx.

                    I’m also using SmartOptimizer on my MODx site (ver 1.04) and have noticed it does a great job minifying and compressing the JS / CSS but for some reason it doesn’t seem to be combining the JS or CSS..I was wondering if you could provide the code you’re using in your solution?

                    Thanks!
                    • Maybe this one (https://github.com/Jako/MinifyRegistered) could do the thing. Since it is working in ’OnLoadWebDocument’ and in ’OnWebPagePrerender’ standard caching should work (not heavy tested now).