lightgallery.js implimentation

trying to implement a lightbox using lightgallery.js my html looks like this
<section id="animated-thumbnails-gallery">
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
</section>
<section id="animated-thumbnails-gallery">
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
<a href="#"><img src="" /></a>
</section>
and javascript is this
lightGallery(document.getElementById("animated-thumbnails-gallery"), {
thumbnail: true,
});
lightGallery(document.getElementById("animated-thumbnails-gallery"), {
thumbnail: true,
});
i tried using this cdn in head as well as before body tag. but it's not working.
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/js/lightgallery.min.js" integrity="sha512-b4rL1m5b76KrUhDkj2Vf14Y0l1NtbiNXwV+SzOzLGv6Tz1roJHa70yr8RmTUswrauu2Wgb/xBJPR8v80pQYKtQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/js/lightgallery.min.js" integrity="sha512-b4rL1m5b76KrUhDkj2Vf14Y0l1NtbiNXwV+SzOzLGv6Tz1roJHa70yr8RmTUswrauu2Wgb/xBJPR8v80pQYKtQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Site link: https://liquid-navbar-88222e.webflow.io/portraits What am I doing wrong?
5 Replies
Abdul Ahad⚡
Abdul Ahad⚡10mo ago
no one here?
Jochem
Jochem10mo ago
maybe I'm missing something, but I don't see it referenced in the site you linked at all what's probably happening though, when you do reference the script, is that the lightgallery.js script isn't loaded and run by the time the script at the bottom of the page is run, so lightGallery isn't defined and can't work
Abdul Ahad⚡
Abdul Ahad⚡10mo ago
so defer would do the job?
Jochem
Jochem10mo ago
you can't defer inline scripts I think you'll have to run lightGallery() inside an onload event listener for the window
Abdul Ahad⚡
Abdul Ahad⚡10mo ago
got it, thank you