public
Created

reload all images every 5 seconds

  • Download Gist
reload_images.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
setInterval(reload_images, 5000);
 
function reload_images(){
$('img').each(reload_image);
}
 
function reload_image(){
var img = $(this), src = img.data('src');
if (typeof src === 'undefined'){
src = img.attr('src');
img.data('src', src);
}
src = src + (/\?/.test(src) ? '&' : '?') + 'at=' + Date.now();
img.attr('src', src);
console.log('reloading', img, src);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.