• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Page Details / Delayed Image Loader

Delayed Image Loader

Delayed Image Loader

General

Use this Image Loader script to delay the loading of a particular image. It can be used to delay the loading of large images or banner advertisements. A smaller image is loaded first, which can be transparent or blank. After a designated amount of time the larger image will load in place of the smaller one.

Notes

  • Created by: Sandeep Gangadharan
  • Web Site: http://www.sivamdesign.com/scripts/
  • Posted: February 2, 2007

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: delayedImageLoader.js

/* This script and many more are available free online at
The JavaScript Source!! http://javascriptsource.com
Created by: Sandeep Gangadharan | http://www.sivamdesign.com/scripts/ */
function runBanner() {
    // change the name of the image below
  document.getElementById('banner').src='large_img.gif';
}

  // change the number below to adjust the time the image takes to load
window.setTimeout("runBanner()", 5000);

Head

Paste this code into the HEAD section of your HTML document.

<script type="text/javascript" src="delayedImageLoader.js"></script>

Body

Paste this code into the BODY section of your HTML document

<img src="small_img.gif" border="0" id="banner">

Page Details

Related Snippets:

  • Check if the browser tab of the page is focused
  • How To Get The Current URL In JavaScript
  • Reload on Resize
  • Calculate the size of scrollbar

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers