devxlogo

Loading Graphics Before You Display Them

Loading Graphics Before You Display Them

Many sites include rollover effects to make images change when the mouse moves over them. However, sometimes there’s an unsightly delay while the second graphic is downloaded from the server. You can avoid this delay with some scripting code to make the client’s browser to load the second graphic at the same time as the page.

In fact you can pre-load several graphics using the same technique. Here’s a JavaScript function to include the header section of your page:

 

Call it by including ONLOAD=”loader()” in the page’s tag and it will load five graphics into the array preLoad ready for displaying. The code can easily be extended to cope with pre-loading as many graphics as you need.

See also  Redefining Energy Management: Advanced Solutions for Modern Buildings
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist