Having found a seemingly excellent solution for loading images after a document's loaded here:
$(function(){
$.each(document.images, function(){
var this_image = this;
var src = $(this_image).attr('src') || '' ;
if(!src.length > 0){
//this_image.src = options.loading; // show loading
var lsrc = $(this_image).attr('lsrc') || '' ;
if(lsrc.length > 0){
var img = new Image();
img.src = lsrc;
$(img).load(function() {
this_image.src = this.src;
});
}
}
});
});
I immediately realized that template languages such as HAML will present a problem since there is no src
attribute to rename directly. I pondered on the possibility of using js to rename all src initially to lsrc
as the dom loaded up and then on document finish to rename them back to src
, but I'm just not sure what the cleanest method may be here.
The bottom line is that I would like to load up images after the html has initially loaded and before the other javascript scriptss load if at all possible.