GlobalEventHandlers.onresized (window.resize)


#1

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.


#2

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


#3

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.