Created
February 14, 2011 07:39
-
-
Save qawemlilo/825594 to your computer and use it in GitHub Desktop.
Load optimisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Qawelesizwe Mlilo | |
Email: qawemlilo@gmail.com | |
Notes: This script is for optimising loading speed for pages with many images. | |
*/ | |
// Mootools | |
window.addEvent('domready', function () { | |
$$("img").each(function (image) { | |
var currentImage = image, og_src = currentImage.src ; | |
if (!currentImage.complete) currentImage.src = "images/place_holder.gif"; | |
window.addEvent('load', function() { | |
currentImage.src = og_src; | |
}); | |
}); | |
}); | |
// JQuery | |
$(function () { | |
$("img").each(function () { | |
var currentImage = this, og_src = currentImage.src ; | |
if (!currentImage.complete) currentImage.src = "place_holder.gif"; | |
$(window).load(function () { | |
currentImage.src = og_src; | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment