2009/4/8 Aude <aude.wiki@gmail.com>


On Wed, Apr 8, 2009 at 10:37 AM, Platonides <platonides@gmail.com> wrote:
Aude wrote:
> I would like to test if a user has JavaScript enabled, which can be done
> with an Ajax call or other way.  If they don't, then don't load all the
> external JavaScript, so as to keep the code lightweight and fast.  If
> the user does have JavaScript enabled, then load the map.js script.
> Depending on the mode selected, the OSM portion of the js can be loaded,
> or the WorldWind portion, or other portion.

Just add it as <script src="whatever/map.js"></script>
If they don't have javascript enabled, they won't load it.

You can load the secondary ones from map.js by using importScriptURI()
or simply add more <script src="">, as the cost is negligible, just one
line.

I wasn't 100% sure, but know that the amount of JS being loaded needs to be minimized and optimized -- even for users that do have JavaScript.  Linking to external JS files is the best way to go, with minimal amounts of JS placed inline by the parser.

We might want to build our own OpenLayers, by not including some of the exotic modules (like support for commercial maps, WFS, etc) to reduce its size. And we should host it on a server that supports dynamic compression of static files (which the normal WMF servers do not, since its done in PHP).

I'm not sure whether it's already possible to load parts of OpenLayers on demand, e.g. in the case where we decide to load Google maps instead of OSM maps.

Regards,

jens