The resize
event fires when the document view (window) has been resized.
In some earlier browsers it was possible to register resize
event handlers on any HTML element. It is still possible to set onresize
attributes or use addEventListener()
to set a handler on any element. However, resize
events are only fired on the window
object (i.e. returned by document.defaultView
). Only handlers registered on the window
object will receive resize
events.
There is a proposal to allow all elements to be notified of resize changes. See Resize Observer to read the draft document, and GitHub issues to read the on-going discussions.
If the resize event is triggered too many times for your application, see Optimizing window.onresize to control the time after which the event fires.