You can use the ResizeObserver API. It's still in it's early days so it's not supported by all browsers yet (but there several polyfills that can help you with that).
Basically this API allow you to attach an event listener to the resize of a DOM element.