Some image lazy loading plugin seems to break the JavaScript code. It tries to inject lazy loading code, but breaks the JavaScript code in the process:
return string.replace(':' + emoji.shortcode + ':', '<img src="data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width='0'%20height='0'%20viewBox=%270%200%200%200%27%3E%3C/svg%3E" loading="lazy" data-lazy="1" decoding="async" class="tf_svg_lazy emoji" data-tf-src="' + emoji.url + '" title="' + emoji.shortcode + '" /><noscript><img class="emoji" data-tf-not-load src="' + emoji.url + '" title="' + emoji.shortcode + '" /></noscript>');
The original source code of the mastodon plugin looks like this:
return string.replace(':' + emoji.shortcode + ':', '<img class="emoji" src="' + emoji.url + '" title="' + emoji.shortcode + '" />');
Typically those optimization plugins allow to define exceptions. If you can define an exception for all images with the class “emoji” it should stop breaking the plugin.
Other quick-fix would be to disable the plugin that breaks the JavaScript code.
Can you provide me with the name of the image lazy loading / optimization / caching plugin that you are using? I might find some time to look into it a bit deeper.
Thread Starter
oidrom
(@oidrom)
Hej Wolfgang,
thank you for your quick reply. You are absolutely right with your tip.
I used the built-in lazy load function of my Themify theme “Parallax”. Unfortunately, you can’t define any exceptions here, so I deactivated it completely. But it shouldn’t be a big performance problem for us either.
Thank you in any case! 🙂
regards
-
This reply was modified 3 months, 2 weeks ago by oidrom.
Glad I could help and that you got it running now!
Another option might be to raise a support request with the theme developer, so that they can fix the wonky code injection.