ResizeObserver

The Resize Observer API provides a performant mechanism by which code can monitor an element for changes to its size, with notifications being delivered to the observer each time the size changes.


RESETRUNFULL
<!DOCTYPE html><html><body style="height:400px">
<textarea style="height:100px; width:200px">Try resizing me...Notice the text here will try to occupy the maximum space regardless of the size and shape.</textarea>
<script>
const resizeObserver = new ResizeObserver(entries => {
   for (let entry of entries) 
      entry.target.style.fontSize = Math.sqrt(entry.target.offsetWidth * entry.target.offsetHeight / 130) + 'px';
});
resizeObserver.observe(document.querySelector('textarea'));
</script></body></html>