Initialization Event Listener Timing
Awesome Library. It has been instrumental in enhancing the functionality and user experience of my projects.
The library's initialization event listener is triggered using window.addEventListener('load', ...). For example:
https://github.com/htmlstreamofficial/preline/blob/be890a54fd41bc0a6d9c379f3c6f1976074962b5/src/plugins/collapse/index.ts#L185
However, this approach delays the event listener binding until all images are fully loaded, causing delayed functionality.
I'd like to discuss potential alternatives or adjustments to the initialization approach. One option could be using the DOMContentLoaded event instead, which fires when the initial HTML document has been loaded and parsed, without waiting for external resources.
Hi! Unfortunately, we can’t do this because some of the plugins should know sizes of the some elements for the correct calculations. E.g. carousel should know the width of the parent element, btw it could be an image in the carousel.
@olegpix Thanks for your response. I think we can decouple the logic of binding the DOM event and the detection of the DOM's box model to trigger separately. If this approach is ok, I'm willing to submit a Pull Request.
@olegpix Thanks for your response. I think we can decouple the logic of binding the DOM event and the detection of the DOM's box model to trigger separately. If this approach is ok, I'm willing to submit a Pull Request.
Hi! Thanks for the active collaboration. We welcome any help from the community. You can make a pull request and we will definitely consider it.