A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

GlobalEventHandlers.onresized (window.resize)

vitim
2016-03-06

I hate to use window.onresize event, but there are situations, that you need to recalculate layout using JS, which is very expensive. And it is very common nowadays with the increasing need to have responsiveness, many sites use this event. The problem is that some page have a huge amount of elements and resizing the window creates a very big hit on even moderate computers. My macbook somethings struggles when trying to resize the browser window.

My proposal is that we should have an event that triggers when the resize has ended, so you can drag the window border to the size you want, then JS will set everything as needed, layout recalculations occurs, then a repaint, just once. not like dozen of times a seconds while resizing.

yoavweiss
2016-03-07

Thanks for your proposal. Fortunately, you’re not alone in thinking this use-case needs addressing, as there’s already an incubation in progress on that subject: ResizeObserver

WolfWar
2016-03-08

I usually nest setTimeout/clearTimeout inside window.onresize with 100-200ms delay to avoid firing event multiple times. Combined with transition effect, you get smooth and fluid movement/resizing of elements at the end of resize event.