Check this link
This plugin loads images / background url after the DOM load event and window load event are triggered.
Initially the src attribute of the img tag will be set to empty. And the html should contain a data attribute which will contain the image path. The plugin will take care of the rest of things.
After image loads, the below code will be executed. All these are handled by the plugin
$('img').attr('src', < data URL with the img path > )