On Mon, Dec 28, 2009 at 3:00 AM, Koen Deforche <[email protected]> wrote: > Hey Richard, > > 2009/12/23 Richard Ulrich <[email protected]>: >> I did some research on the internet. Other people seem to have similar >> problems with javascript libraries that depend on other javascript >> libraries. It has nothing to do with Wt. >> If I remember correctly, the browsers load the script libraries parallel >> and serialize only by host. Because the google maps librariy comes from >> another host than the additional library, the browser thinks it can load >> them both at the same time. There are some lazy loading libraries. But >> combining them with Wt seemed to be difficult. > > Interesting. I had always imagined that JavaScript really executes in > the order of declaration. Do you have a link that suggests a > particular solution which you help if it were implemented by Wt itself > ?
You know how Google has a public repository of many popular Javascript libraries at http://code.google.com/apis/ajaxlibs/ and it works around it by requiring you to call startup functions. First you include the root source (which is 'safe' in that it will not conflict with any other things loading at the same time), then you call the things that you wish to load later on. Here, take a look at the example on that above link: <script src="http://www.google.com/jsapi"></script> <script> // Load jQuery, latest of version 1 google.load("jquery", "1"); // Load Google's search API, latest of version 1 google.load("search", "1"); // Load Google's feeds API, latest of version 1, disabling its use of css google.load("feeds", "1", {"nocss" : true}); // Load Yahoo's user interface library, version 2.8.0r4 google.load("yui", "2.8.0r4"); function mapsLoaded() { var map = new google.maps.Map2(document.getElementById("map")); map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13); } function loadMaps() { // Load Google's maps API, latest of version 2 google.load("maps", "2", {"callback" : mapsLoaded}); } </script> It causes it to serialize all loading of the external libraries, and can even lazy-load then, like the maps api in the example above, if they are needed (where the mapsLoaded callback is called when the loading is complete). Google also has a way to encode loading a lot of libraries at once in the src parameter itself to decrease loading times even further. Perhaps Wt can create a loading function as well that can be called to load an external script to ensure things are kept serialized if this is really a problem? ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
