When creating a website, a priority is to make your website load faster. That’s good!
But what are you doing if your website is embeding some images who doesn’t exist?
Example:
View Code HTML
<img src="http://example.com/my-image.jpg"> |
If the image (my-image.jpg in our example) doesn’t exist, your website will get loaded more slowly but if you user the .error event from jQuery you can solve this problem easily.
Example:
View Code JAVASCRIPT
$(document).ready(function() { $('img').error(function(){ $(this).attr('src', 'http://example.com/image-not-found.jpg); }); }); |
So this script changes the image source to the error image (image-not-found.jpg) in our example) and your should not have any problem visiting your website.