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

Optimize useKWindowDimensions performance #461

Closed
MisRob opened this issue Oct 2, 2023 · 2 comments · Fixed by #469
Closed

Optimize useKWindowDimensions performance #461

MisRob opened this issue Oct 2, 2023 · 2 comments · Fixed by #469
Assignees
Labels
Component: KResponsiveWindowMixin good first issue Self-contained, straightforward, low-complexity help wanted Open source contributors welcome

Comments

@MisRob
Copy link
Member

MisRob commented Oct 2, 2023

Summary

In useKWindowDimensions, we read window.innerWidth/Height on each resize event

window.addEventListener('resize', eventHandler, true);

width: window.innerWidth,
height: window.innerHeight,

This is not good performance-wise since reading innerWidth/Height causes layout/reflow.

It'd be good to debounce the event handler calls so that innerWidth/Height is not read so often.

lodash/debounce is available in this repository for that purpose.

References

@MisRob MisRob added Component: KResponsiveWindowMixin good first issue Self-contained, straightforward, low-complexity help wanted Open source contributors welcome labels Oct 2, 2023
@nucleogenesis nucleogenesis added this to the KDS Priority Triage milestone Oct 3, 2023
@Jaspreet-singh-1032
Copy link
Contributor

Hi @MisRob, Please assign this issue to me.

@MisRob
Copy link
Member Author

MisRob commented Oct 10, 2023

Thanks @Jaspreet-singh-1032, assigning you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: KResponsiveWindowMixin good first issue Self-contained, straightforward, low-complexity help wanted Open source contributors welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants