This analogy can be compared to for example, a set of Traffic Lights. You may have seen it sometimes when traffic lights are not functioning correctly, or sometimes you’re in a queue and you’re saying “for god sake, the lights don’t stay green long enough.” So it may stay green for about 5 seconds, which is just enough time for you to pull down the hand brake, accelerate and go. In that time you may get about 5 cars though for example. Now lets say the lights go green for 10 seconds. Now you may expect to get 10 cars through, but you may get 15 through. The time to negotiate the hand brake, accelerating and stopping is less frequent, so we are maximizing throughput. Read on: http://sumo.sourceforge.net/docs/dkrajzew_TRAF9_AgentbasedTLS.pdf
This is the same for negotiating each request in our case. I have seen a lot of different ways of people achieving script combining. Most commonly and a good way is to use a Handler, that returns the combined result. I have a handler that works in a similar way, but it can be implemented in a more friendly manor using a Custom Server Control.
The control has other configurable properties, such as caching, minifying and compressing. They are all switched on by default. The code below will look familiar to the ASP.NET AJAX Script Manager, script combining, but the control I wrote gives you more control over caching, minifying and compressing (using GZip).
It can be implimented like so.
<cc:ScriptCombine ScriptHandler="~/ScriptCombine.ashx" ID="ScriptCombiner" runat="server">
<cc:ScriptPath Path="~/Scripts/jquery-1.3.2.min.js" />
<cc:ScriptPath Path="~/Scripts/ui.core.js" />
<cc:ScriptPath Path="~/Scripts/ui.accordion.js" />
You can download an example project with the source code: Download
You can script combine in your project by taking the ScriptCombine.ashx and the CustomControls.dll and reference accordingly like the example.