[Geoprisma-dev] Dynamically loading JS
Yves Moisan
yves.moisan at boreal-is.com
Mon Mar 29 17:08:01 EDT 2010
Le 2010-03-29 16:00, James McGrath a écrit :
>
> Hi list,
>
> I just got an idea that I'm just throwing like that that could help
> reduce the quantity of JS loaded on startup of geoprisma. Some
> widgets are loaded in stand-by to be used (And probably won't be used
> in a typical session), we could change heavy widgets so it loads only
> when first called by including the JS dynamically using this :
>
> ---------------------------------
>
> var script = document.createElement('script');
>
> script.src = "widget/foobar/dynaJS.js";
>
> script.type = 'text/javascript';
>
> script.defer = true;
>
> var head = document.getElementsByTagName('head').item(0);
>
> head.appendChild(script);
>
> ---------------------------------
>
> I'm using this sort of dynamic script inclusion for another project
> and so far it works with every browser we used. I think it could help
> a little for a js hungry implementation.
>
Hi James,
Do you have any comparison as to the time it helps save ? I think most
of the juice comes from the minified OL-MF-GeoEXT JS file but that's
only in one file and when used in conjunction with mod_deflate it boils
down to just under 200 KB. Each GP widget includes a separate JS file
so maybe just minifying those together in one file for all GP widgets
would help both save bandwidth and we wouldn't have to fiddle with
conditional JS inclusion. All in all, we'd have 1 JS download for
OL-MF-GeoEXT and another for GP.
What do others think ?
Yves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geoprisma-dev/attachments/20100329/2d2b35ae/attachment.html
More information about the Geoprisma-dev
mailing list