View Full Version : preload all script library before UI appear?

27 Oct 2006, 2:07 PM
Hi Jack,
Is there a way to do preload all the script library before the UI actually display? I think the YUI library size is pretty big ..it would be nice to let the user know the browser is currently download the library or associated files. Thanks


27 Oct 2006, 2:22 PM
You can create an element with a position:absolute; left: 0px; top: 0px; background-color:white; width:100%;height:100%;z-index:50000; and put it at the very top of the body. In that element put another positioned element in the middle that says loading or whatever and has your fav animated loading icon.

After this element, put your script includes.

When the page loads and you initialize your app:

var loading = document.getElementById('loading-id');

and you are ready to go.

27 Oct 2006, 2:44 PM

4 Nov 2006, 8:00 AM
well if you include the javascript in the head section of an html document... youŽll not be able to use this because the user cannot see any output before the complete YUI files have been transfered to the client...

You have to include it inline in the body section ...
[script type="text/javascript" src="plugin/yui/build/yahoo/yahoo.js"></script]

4 Nov 2006, 2:24 PM
You are right Hors, that's why I said "After this element, put your script includes.". ;)