midzer / tobii

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

Optimizations issues #82

Closed viliusle closed 2 years ago

viliusle commented 2 years ago

This lib will builds huge list of tobi__slider elements on page load. During this time, JS blocks everything else like user input, page rendering and so on.

And now google penalize sites for being slow. So this should be fixed.

What can be done? On load create only basic DOM elements, like container, buttons. Only when user does click, do heavy work to display something using lightbox effect.

Dom-tree

viliusle commented 2 years ago

I still need to do more test to make sure that creating lots of DOM elements is a problem. Problem could be somewhere else of course.

p.s. confirmed. Adding lots of created sliders into DOM take most JS processing time.

viliusle commented 2 years ago

Another improvement idea: don't do anything if there are 0 targets to show modal window from.

viliusle commented 2 years ago

Issue was with creating multiple empty iframes on page load. Even src is empty, this process is very slow. I fixed it by creating iframes only when user clicks on target element (only when needed.)