Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include polyfill #71

Open
unindented opened this issue Mar 5, 2018 · 3 comments
Open

Do not include polyfill #71

unindented opened this issue Mar 5, 2018 · 3 comments

Comments

@unindented
Copy link

Including the ResizeObserver polyfill makes this module unnecessarily heavy. Apps should be lazy-loading polyfills, so that they don't ship unnecessary code to modern browsers.

Would you consider shipping this module (or a version of this module) without the polyfill?

@d6u
Copy link
Member

d6u commented Mar 14, 2018

Sorry for the late reply, sounds like a good idea. I will find some time for this maybe this weekend. Also PR is welcome.

@unindented
Copy link
Author

@d6u we can create a PR, with a bit of guidance... How would you go about it? Would you remove the dependency on resize-observer-lite completely?

@swese44
Copy link

swese44 commented May 10, 2018

react-container-query uses resize-observer-lite to listen to change events to re-render the react component tree:
https://github.com/d6u/react-container-query/blob/master/src/ContainerQueryCore.ts#L11

resize-observer-lite prefers to use the browser's window.ResizeObserver directly, but if not present will use element-resize-detector's custom API to listen to resize changes:
https://github.com/d6u/resize-observer-lite/blob/master/src/index.ts#L11

unfortunately element-resize-detector is not a polyfill we could conditionally load, it's a custom API.

i believe element-resize-detector is already polluting the global namespace by creating window. elementResizeDetectorMaker. resize-observer-lite's main file could remove its dependency on element-resize-detector and fall back to window.elementResizeDetectorMaker (maybe also wrapped in a conditional to prevent errors if not included). then to prevent breaking current consumers, react-observer-lite could import element-resize-detector in a separate file which gets imported in the build step, but adds another build step which generates an alternate dist without importing element-resize-detector. react-container-query would also need to provide a second dist without the element-resize-detector dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants