Well, to speed things up, you could get rid of the preloading. This will mean that the users will have to wait for however long it takes to load each individual image at the time of each tip's first appearance before the image will be seen. To do this, remove this from the code:
Code:
// preload images that are to appear in tooltip
// from arrays above
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
Or, you could wait until the page is otherwise loaded before preloading the the images. This might be the best compromise under the circumstances. To do this, change the above to a function, like so (additions red):
Code:
// preload images that are to appear in tooltip
// from arrays above
function preloadImages(){
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
}
Then in the init() function (which fires only after the rest of the page is loaded), do a call, like so (addition red):
Code:
///////////////////////////////////////////////////////////
// initTip - initialization for tooltip.
// Global variables for tooltip.
// Set styles for all but ns4.
// Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
preloadImages();
if (nodyn) return;
tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
tipcss = (ns4)? document.tipDiv: tooltip.style;
if (ie4||ie5||ns5) { // ns4 would lose all this on rewrites
tipcss.width = t . . . snip . . .
This can still result in, at times, the users having to wait for the tip images to load upon first activation of a given tip but, it is less likely and, the longer the page is loaded in the browser, the less likely this will become.
Bookmarks