I'm using the jQuery code below to replace part of the image src. Basically it converts example.com/200x200/sample.jpg into example.com/500x500/sample.jpg.
It works fine only problem is it renders the old image first before showing the new one. Is it possible to load the swapped image first to improve user experience?
$(document).ready(function() {
$(".gallery img").each(function() {
$(this).attr("src", function(a, b) {
return b.replace("200x200", "500x500")
})
})
});
JSFiddle Demo (Click "Run" multiple times)