We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15175
    • 116 Posts
    In order to reduce page load time it seems that combining all your JS and CSS files in to 2 http requests is the way forward.

    I’ve tried two different methods, but I just can’t get it to work:

    http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files

    http://www.ejeliot.com/blog/72


    I’m not sure if it MODx related or not, so it would be good to hear if anyone is using one of the above methods, or something similar.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Two points; you’ll need to convert the <?php ... ?> part to a snippet, and the snippet would have to return something. Presumably the included php code returns the filename, so your snippet in turn would need to return it. Don’t try to return the include function; all you’ll get doing that is the success/failure return code of the include function! Most likely you’ll have to hack the script a bit to get its return value (the filename) into a variable, then have your snippet return the variable.
        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
        • 15175
        • 116 Posts
        Thanks for replying Susan.

        In the first method the php script is called from an .htaccess file - I’m guessing that a snippet call can’t be used there. The second method gives the option of using a ’require’ to include the php - I don’t understand how to use a snippet in the context it asks for. If I did understand that, then hacking the actual script to get the required return value is probably well beyond my powers.

        I think I’m just going to have to cut and paste everything into two separate files instead.

        Thanks anyways.
          • 15175
          • 116 Posts
          Somebody might find this useful - I have stumbled across ’minify’;

          http://code.google.com/p/minify/

          As well as combining scripts, it also compresses and gzip’s.