scaleflex/js-cloudimage-responsive

Allow ciResponsive.process to use a custom root element

Closed this issue · 1 comments

In some cases we trigger window.ciResponsive.process() on-demand to load images that were not present at the initial page load run. I noticed that the process function processes all images of the page every time it is called:

images = filterImages(document.querySelectorAll(`img[${this.config.imgSelector}]`), 'ci-image');

I think this could be enhanced by providing a second argument to process which would be a Node element. This would be a non breaking change. That way we could use this parameter to change the root from which the querySelectorAll is performed. It would only search from a sub part of the DOM rather than the whole document every time. This would prevent unnecessary work in our use case. If not provided the current behavior would remain.

What do you think? I'd be happy to open a PR for it if that's an enhancement you'll accept.

Thank you.

hey @Nargonath ,

Sure, it's a great enhancement proposition. And your PR will be kindly checked and merged :)

Feel free to ask any questions or help