$.fn.preload = function (callback) { var length = this.length; var iterator = 0; return this.each(function () { var self = this; var tmp = new Image(); if (callback) tmp.onload = function () { callback.call(self, 100 * ++iterator / length, iterator === length); }; tmp.src = this.src; }); };
Использование довольно просто:
$('img').preload(function(perc, done) { console.log(this, perc, done); });