Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Possible Duplicate:
Optimizing for load time VS staying organized

I would like to speed up my website, and one of the ways YSlow! talks about is to reduce the number of files being downloaded during a request.

How does one solve this problem, when having multiple javascript (or css) files (jquery.js, jquery.cycle.js, own js file)? I would prefer not to merge them myself.

share|improve this question

migrated from serverfault.com Oct 14 '11 at 22:32

This question came from our site for professional system and network administrators.

marked as duplicate by Su', John Conde Oct 15 '11 at 13:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 1 down vote accepted

I would recommend minify if you don't want to manually combine files, this will do it for you on the fly and create one combined/minified file.

share|improve this answer

It would theoretically be possible for a filter (implemented as an Apache module for instance, or in a reverse proxy that content from the web server passes through) to:

  1. Scan output for calls to scripts or css files
  2. Get those files, and replace the or tags with their content
  3. Cache the result for a while so it can just output it next time with less effort

This would have performance problems of its own though, as the user would end up downloading the script file on every dynamic page request instead of it being able to be cached separately on their machine. This could be worked around by having the filter instead replace a calls for "script1.js", "script2.js" and "script3.js" with "combined_script1_script2_script3.js and then responding to that request with the combined script files (and the same process for styles).

Unfortunately I am not aware of any filter/proxy readily available that works this way, though you might want to scan the documentation for content shrinking proxies (those that recompress images, minify html/script/style, and so on) and to see if they can do something like this.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.