amp-iframe-resize-child

A teeny tiny (0.37 kb before gzip) resize handler for child iframes, that supports the [AMP-style resize event messages](https://ampbyexample.com/components/amp-iframe/#resizable-iframes).

Usage no npm install needed!

<script type="module">
  import ampIframeResizeChild from 'https://cdn.skypack.dev/amp-iframe-resize-child';
</script>

README

AMP iframe resize emitter

A teeny tiny (0.37 kb before gzip) resize handler for child iframes, that supports the AMP-style resize event messages.

Use this module if you're creating content that will be consumed in AMP articles that needs the parent frame to be resized to fit.

This script binds a mutation observer to the body & listener to the resize event so it will check for changes to dimensions whenever your content does, or if the window resizes.

Usage

Install the package from NPM (npm i amp-iframe-resize-child);

Then add the listeners like so:

const resizeHandler = require('amp-iframe-resize-child');
resizeHandler();

You might likeā€¦

If you liked this module, you might also like the amp-iframe-parent-resize module which lets your non-AMP parent page handle resize events from AMP articles such as this.