From 4bbaf4a5db12f2fa8b9b3043d5363a24de04cef9 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 1 Apr 2024 19:06:33 -0400 Subject: [PATCH] refactor: Add the dynamic loading of LazySizes back in --- src/templates/frontend/lazysizes-fallback.twig.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/templates/frontend/lazysizes-fallback.twig.js b/src/templates/frontend/lazysizes-fallback.twig.js index 5167049..0e99031 100644 --- a/src/templates/frontend/lazysizes-fallback.twig.js +++ b/src/templates/frontend/lazysizes-fallback.twig.js @@ -24,4 +24,9 @@ if ('loading' in HTMLImageElement.prototype) { source.removeAttribute('data-sizes'); } }); +} else { + // Dynamically import the LazySizes library + const script = document.createElement('script'); + script.src = '{{ scriptSrc }}'; + document.body.appendChild(script); }