Hey,
here are some strategies for loading JS:
Page A needs JS file 1,2,3,4,5
Page B needs JS file 2,3,4,5,6
In order to minimize http requests, the strategies would be to
Strategy X:
1. Visit page A , load a package containing all needed JS files
2. Visit page B, once again load a package containing all needed JS files
plus: Simple
minus: Loading too much data
Strategy Y
1. Visit page A, load a package containing all needed JS files
2. Visit page B, somehow determine that we were already in Page A and
use that package plus and extra request for file 6
plus: Minimal data
minus: Very complex, needs support on the server for dynamically
assembling JS packages.
Strategy Z:
1. Visit page A Load a package containing all needed JS files for the entire App
plus: Simple
plus: Maximum result from zip-compression
minus: User loads code which he might not need eventually
My current thinking is, that if (and only if) the package resulting
from strategy Z is not "too large" it is the best strategy most of the
time.
If it is possible to easily determine disjunct packages of JS files,
it makes of course sense to load these separately. In this case, it
is, however, highly likely that we are talking about separate
applications anyway.
Bye
Malte