I've made some changes to optimize the code that handles window size changes. Here's what I've done:
I removed the repeated logic for getting the window size and instead used a reusable function to get the size once and store it in a variable.
I added a debouncing mechanism to the resize event listener to prevent the function from being called too frequently.
I used requestAnimationFrame to throttle the resize event and only call the function once per animation frame.
These changes should improve performance and reduce the number of unnecessary function calls.
Let me know if you have any questions or concerns.
I've made some changes to optimize the code that handles window size changes. Here's what I've done:
I used requestAnimationFrame to throttle the resize event and only call the function once per animation frame. These changes should improve performance and reduce the number of unnecessary function calls.
Let me know if you have any questions or concerns.