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.

-Kate
 



_______________________________________________
Maps-l mailing list
Maps-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/maps-l