document.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('#chat_messages img, .with_code img').forEach(function(img) { img.onerror = function() { this.style.display = 'none'; }; if (img.complete && img.naturalWidth === 0) { img.style.display = 'none'; } }); });