i'll preface this by saying that i am not the most accomplished coder. i apologize if there is an obvious answer to this. i also apologize if this would be better in feature requests or usage support.
discovery of the yslow and pagespeed plugins for firefox has tickled my OCD tendencies. i'm attempting to develop a theme that implements some of yahoo's best practices for speeding up web sites (
http://developer.yahoo.com/performance/rules.html). implementing eTags, expires headers, gzip compression, and css sprites has helped performance a lot, especially after the first page load.
one of the rules i'm having trouble with is the saying to combine external javascript into one file in order to reduce http requests. since several plugins have their own js to load, i'd like to have a php file load all of those files into that one file and then call it from the theme pages. it was not too bad to get the jquery and zenphoto.js.php files into the file using simple `include()` calls. the trouble is trying to get any of the plugin scripts. when used outside of `zenjavascript()` (ie the php file i've made), the variable `$_zp_plugin_scripts` is empty.
any advice or ideas about getting the plugin javascript into my file would be appreciated. also if anyone can think of reasons not to do this (server time vs. client time, etc.) please share. it could also be that it doesn't matter much since eTags should be allowing the browser to cache scripts after the first page load that uses them.
Comments
The problem is that the plugins provide no direct links to the js files but the ``setup so I think you would have to extract the actual url first before you can directly include them. Then you probably have to create a static cached page of that so you don't need to do the same all the time.
I found this quickly online that might help you: http://www.thewebshop.ca/blog/2009/11/combining-css-or-javascript-files-on-the-fly-with-php/
Generally I am not sure if this makes a noticable speed up for the actual visitor but I know about the recommendation to limit request.
I would recommend to try to do a plugin for this so it is not theme dependent and maybe of use for all.
You might also want to look at static_html_cache plugin that caches all theme pages.
It is nice to have "rules" to follow to make things better. We have one as well--we do not modify third party scripts unless absolutely necessary. This prevents problems with support of their functionality. So, I guess your "rule" to make a website better is in direct conflict with a pretty basic rule of software development. Keep things modular and independent. Guess which rule will prevail with Zenphoto.
@acrylian - the static cache would probably speed things up on the backend so thank you for that additional piece of advice.
@sbillard - i am trying to keep changes limited to the theme itself. it is my understanding that concatenating all of the js into one file should not change the behavior of how it is implemented. i do appreciate the reminder. it fits with acrylian's advice to make it a plugin. i don't think it would be tough to make the php on theme pages check for the plugin and just run the standard zenJavascript if it is not.
thanks again to the whole zenphoto team. it's a great tool with a great community and developers.