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