Closed curiositry closed 9 years ago
Is this project still active?
@omphalosskeptic sorry, havent seen your comment! I will continue developing as soon as I finish my other (paid ;) ) projects.
how do you init the lightbox, i.e. when? or how do you make sure atm that the lightbox is loaded before you init it?
@felixhagspiel Thanks for your reply. Right now I’m doing it how you suggest in the readme (include the script, not deferred or async, then init in a script directly below).
can you send the console print? if you load the lightbox async then you have to wait until it is loaded before you init it. Try this and tell me if it works:
<script async src="js/lightbox.js" type="text/javascript"></script>
<script>
var interval = window.setInterval(function(){
if(Lightbox) {
var lightbox = new Lightbox();
lightbox.load();
window.clearInterval(interval);
}
},50);
</script>
also, if you put the scripts at the bottom the DOM is ready when the lightbox is loaded. Except if you load the website content async. But then you should execute the init of the lightbox after the content is loaded, i.e. in the success-callback of your ajax call
@felixhagspiel That seem to work. Thanks for responding to my poorly thought-out question!
When I defer the lightbox.min.js script, or load it asynchronously, it breaks.
Did I miss something, or is there any way to get around this? All the other scripts in my project are loaded async or deferred, and I’d prefer not to have a lightbox — which won’t be used until the content is ready — holding up the show.
Thanks!