We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11337
    • 19 Posts
    Hi. I have the problem with pretty nice method of js compress, plz look at:
    http://wyome.com/index.php?module=articles&func=display&ptid=2&aid=362

    After rename paths in modx and files names on .php extension.. my javascript doesn’t work at all. How to include this method into modx website? to work correctly? Whats could be a reason: modx bug or server misconfiguration?


    Web Server:
    ----------------
    MySQL 4.0.23
    Apache/1.3.33 (Unix)
    PHP/4.3.11 mod_perl/1.29
    Linux 2.4.20-021stab028.19.777-enterprise
    Intel(R) Xeon(TM) CPU 3.06GHz

    Browser/Client:
    -----------------
    Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8) Gecko/20051111 Firefox/1.5 , opera 8
    Ubuntu/ Linux
      • 32241
      • 1,495 Posts
      Hi,

      I’m not to for sure about this, but as far as I know, MODx is compressing their html output automatically. It means that whatever content that you put on the MODx system, it will be compressed automatically.

      So for all css and javascript file that you want to use, you can import it into MODx, and change the type of the content into css, xml or whatever that you want to choose. This content will be outputed in a zip format.

      Someone from the core team, please correct me on this, if I’m getting the wrong idea about MODx is able to compress stuff automatically.

      Thanks
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
      • MODx does not apply any compression to the content, but the default .htaccess does enable gzip output compression via the PHP parser on servers that support this.

        But it does bring up some ideas on reducing the site of the content returned to the browser using MODx plugins. The issue with this script, I would imagine from a quick peek, is it is trying to set output compression to the file using ob_start, which I imagine conflicts with the output buffering used inside the MODx parser. I’ll see if I can find an alternative approach for accomplishing this in MODx. Shouldn’t be difficult.
          • 32241
          • 1,495 Posts
          I would imagine using plugin to snap the output buffer from modx and compress it?
          Anyway, I’ll leave the rest to your Jason tongue Hehehe...
            Wendy Novianto
            [font=Verdana]PT DJAMOER Technology Media
            [font=Verdana]Xituz Media
          • If the compressed file is being included from the document at run-time (as are css and js files), these files are retrieved in separate browser requests; any processing being done would be totally separate from MODx. On the other hand, if you are using MODx documents for these, I can see where it would definitely be a problem, since MODx is already processing them. In that case, I think you would need to first add a line of code closing the object that MODx opens.

            Hmm...it might be interesting to add this compression to the parser in the case of css and javascript file types along with fixing the file extension/friendly url issue? A plugin might be a better idea?

            If you’re using external .css and .js files, this might help isolate the problem:

            Try some simple tests without using MODx at all; make an html document and a compressed css or js file and put them in a separate directory on your web site and access it directly from the browser. The MODx engine won’t be involved, and you’ll be able to see what these files are doing by themselves.

            [edit]I’ve just done this, and it works fine. Modified my MODx templates to use this, and they also work fine. Unless I’m misunderstanding something? All I did was to change the included file names in my template (both for stylesheets and for js script includes) to xxx.php, and added the little block of code to the .css and .js files and renamed them. I didn’t mess with the .htaccess method. Too "iffy" for different shared hosting systems and configurations.
              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
              • 11337
              • 19 Posts
              Solution is that there is no need for having ob_start ("ob_gzhandler") line in the code snippet - beacause modx uses zlib compression smiley)

              .. but I have problem with htacces method (testing on simple static html). After insert this code into .htaccess:

              AddHandler application/x-httpd-php .js
              php_value auto_prepend_file gzip-js.php
              php_flag zlib.output_compression On

              JS are comprssed well but doesn’t work!! sad What could be a reason?
                • 31337
                • 258 Posts
                On a somewhat related note, check out this article:
                http://www.zimbra.com/blog/archives/2006/01/zimbra_ajax_css_digg.html