Displayed here are the basic abilities of the ImageLoader Utility. Images are loaded only after triggers are fired or time limits are reached.
Hover over each image to show its triggers and its time limit. Try tripping the triggers to see the load reactions. Refresh the page to reset the images.
The ImageLoader Utility allows you to define the conditions under which images are loaded into the page. This example demonstrates attaching some simple triggers to images to establish this load control.
The HTML used for the image needs little to no modification. Simply make sure the image elements have
id attributes, eliminate the
src attribute from
<img> elements, and optionally declare
<img> elements as having hidden visibility.
Starting with the architectural image at the top. We set a
mouseover of the image itself as a trigger, and a 2-second time limit.
The second group has two images, and also two triggers. As triggers, we have a
mouseover of the left image and a
click on the right image.
The third group has no trigger; the only thing that will load the image is its time limit of 5 seconds.
In the last group, we have an image loaded by the window's
scroll event. Since this is an
<img> element, we omit the
src attribute. Also, we'll set the visibility to hidden to avoid a broken image icon. (Our other option is to use a transparent image as the source, but the tradeoff is the load burden of this additional image.) Because we've hidden the image, we need to make sure it gets changed to visible via the
setVisible flag. This group has no time limit, so the only thing that will load the image is its