[wp-trac] Re: [WordPress Trac] #3372: Consolidated JavaScript/CSS
Plugin API
WordPress Trac
wp-trac at lists.automattic.com
Sat Dec 6 03:25:48 GMT 2008
#3372: Consolidated JavaScript/CSS Plugin API
-----------------------------+----------------------------------------------
Reporter: robertaccettura | Owner: anonymous
Type: enhancement | Status: new
Priority: low | Milestone: 2.8
Component: Optimization | Version: 2.1
Severity: minor | Resolution:
Keywords: |
-----------------------------+----------------------------------------------
Comment (by xenlab):
This is a great idea. On other systems that I've done this with, the
bandwidth and HTTP request savings were ENORMOUS! For high traffic sites
(1M+ per day) you'd be silly not to do this, since saving those extra
requests mean you can serve more traffic with the same hardware stack.
I've seen it. It really is amazing.
With the evangelizing aside, I want to address a couple of comments, and
then add my own two cents...
First styles never conflict, they cascade. The order the files are added
should be something that is respected. I believe this is already being
taken into account. If you are using conditionals, they will probably go
under the aggregated file and pick up the cascade (applying only to IE)
after the fact, to fix IE's lovely bugs.
If scripts are conflicting, then there is a problem long before the
aggregation takes hold. All this should do is concatenate the files, one
after the other, into one 'super' file, so that is only one file to be
served up.
This shouldn't be done dynamically on each page load. The file should be
created and cached to disk. This way the file can be pre-generated on the
first request, but fetched from disk on all other requests.
While there would be a little processing overhead upfront, I think it
should md5 the file contents and use this hash as the file name. This way
if new files are added, they could be checked against the hash and regen'd
as needed. This has the added benefit of always serving a fresh aggregate
file if the contents have changed, forcing user agents to update their
local cache because the md5 hash file name would change. Speed tests would
need to be performed as this may be more trouble than its worth, but
md5'ing at least the original file names would be a good way to come up
with a naming convention.
In addition you should include a way to for scripts to be able to 'target'
wp_head or wp_footer. This way you can add some scripts in the header if
that's whats needed but put the majority of scripts near the footer so
that they fire after the page has loaded. This could be easily
accomplished with a paramater to the add_js function.
And last but not least, we should be gziping the file that's output.
--
Ticket URL: <http://trac.wordpress.org/ticket/3372#comment:11>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list