Actually, I was thinking something more like this:

https://github.com/gem/oq-platform/blob/master/oq-ui-client2/src/exposure/exposure_export.js#L104

Abstract the resize commands into a function, and then hook the function into the document.ready and window.resize events: https://github.com/gem/oq-platform/blob/master/oq-ui-client2/src/exposure/exposure_export.js#L168