Member Login


Find and hide broken images in js

Ever run into the issue where dynamic content loads on a page and occasionally contains a broken image icon (and a 404 on the get request for the image)? Well, I have…

So here’s my plan:

Then you can bind this to the window and search for all img tags:

Or if you’re using jquery:

Obviously you could do more than set the visibility to hidden: Add a class to the deviant images, remove from DOM, display: none, add a pink border, destroy the DOM at first instance of a broken image, etc…

This entry was posted in Coding, Technology. Bookmark the permalink.