Background
Why we updated
We have just updated the lazy module to deal with the deprecated warnings with PHP 8.3 and thankfully, they seem to have gone away now. Nice
IFRAMES in v8.x-3.13
We understood from previous advice that the lazy module did not support the
iframe field →
module and we were advised to deal with it by implementing a field template for that module in our theme in templates/iframe.html.twig
like this…
<div{% if attributes.class is not empty %} class="{{ attributes.class }}"{% endif %}>
{% if text is not empty %}
<h{{ headerlevel ?? 3 }} class="iframe_title">{{ text }}</h{{ headerlevel ?? 3 }}>
{% endif %}
<style>{{ style|raw }}</style>
<iframe class="lazyload"{{ attributes|without('class','src') }} loading="lazy" data-src="{{ src }}">
{{ 'Your browser does not support iframes, but you can visit <a href=":url">@text</a>'|t({ ':url': src, '@text': text }) }}
</iframe>
</div>
This worked a treat and we had <iframe> fields here, there and everywhere lazily loading all day long ;-)<?p>
Since the update to 4.01
Since the update to 4.01 and one or two cache-clears later, we don't seem to be getting the content of <iframes> loaded at all — the #document
is all but empty.
As a check, temporarily removing our custom template from the equation brings the <iframes> back into the rendered page but they are of course no longer lazy loaded but the experiment seems to confirm that there is now something amiss/outdated with our template in respect of lazy 4.01
I hope I have explained that clearly enough.
We have also noticed that we are seeing the following errors in the browser console and wondered if that might be connected…
Uncaught ReferenceError: TRUE is not defined
at Object.loadScript (lazy.js?v=10.3.1:27:28)
at Object.attach (lazy.js?v=10.3.1:57:17)
at drupal.js?v=10.3.1:166:24
at Array.forEach (<anonymous>)
at Drupal.attachBehaviors (drupal.js?v=10.3.1:162:34)
at big_pipe.js?v=10.3.1:153:10
at big_pipe.js?v=10.3.1:184:3
drupal.js?v=10.3.1:64 Uncaught ReferenceError: TRUE is not defined
at Object.loadScript (lazy.js?v=10.3.1:27:28)
at Object.attach (lazy.js?v=10.3.1:57:17)
at drupal.js?v=10.3.1:166:24
at Array.forEach (<anonymous>)
at Drupal.attachBehaviors (drupal.js?v=10.3.1:162:34)
at drupal.init.js:32:12
at HTMLDocument.listener (drupal.init.js:20:7)
Any help and advice gratefully received.
Thank you