midzer / tobii

An accessible, open-source lightbox with no dependencies
https://midzer.github.io/tobii/demo/
MIT License
196 stars 20 forks source link

Lazy loading for iframes / on demand loading #111

Closed roborourke closed 1 year ago

roborourke commented 1 year ago

Hey, this is a great lightweightt library - thanks for open sourcing it.

One thing that's come up for us is around performance and loading iframes in straight away. I'm wondering if the simple addition of loading="lazy" on the iframes would be enough to make this possible.

Alternatively could the youtube script loading and iframe creation be deferred to when the lightbox is first opened perhaps?

viliusle commented 1 year ago

When you expect user to open youtube video, video will take some time to load. And we have 2 ways of showing youtube videos:

So you can choose. I personally recommend iframe. Check demo for methods.

roborourke commented 1 year ago

Closing out - we used the iframe approach instead of API, thanks for the response.