An Iframe Resizer Alternative
If you’ve ever embedded content using <iframe>
, you know how tricky it can be to get the sizing just right.
For a long time, the go-to solution was the Iframe resizer library, which works very well. However, with its recent switch to a commercial license,
developers like myself found themselves in need of an alternative, so I created Open Iframe Resizer, a lightweight, open-source solution under the MIT license.
Features
The first version is quite simple, you inject the script, and your browser resizes the registered iframes, this version also supports cross-origin iframes, which works with postMessage API as the parent window cannot alter cross-origin iframes child document for security reasons.
This library provides an alternative usable in commercial closed-source projects. Moreover, the library is fully typed, and I’m trying to keep the original lib API to ease the migration.
The core package is available here and a React component is also available here.
Limitations
The library supports Chrome 64+ (2018). This limitation comes from the ResizeObserver
API, which could be polyfilled, although it is not a priority in the current version.
Additionally, it currently lacks some features from the original library, such as injecting styles into an iframe.
Try it out
Feel free to check out the full source code and propose a PR or a feature you want to have. If you find it helpful, don’t forget to star the repo and spread the word!