Remove duplicate image direct from the website using JQuery fn

We can remove the duplicate image from the website by using this function . We find image with their source in the website so if we want to delete it we can make a if condition there so that it will take only one different source files. Using Jquery fn :

<script>

$(document).ready(function() {

var img = $(“img”);

var used ={};

//console.dir($(img[0]).attr(“src”));

img.each(function() {

var src = $(this).attr(‘src’);

if(used[src]) $(this).remove();

used[src]=1;

});

})

</script>

Leave a comment

Your email address will not be published. Required fields are marked *