Search code examples
javascriptiframeinternet-explorer-11polyfillsbabel-polyfill

How do I transfer polyfills to an iframe?


I'm making a website compatible with ie11. I use babel to transpile the code and then I run a script in index.html that checks what needs to be polyfilled and import each polyfill dynamically.

In one part of my code, I have an iframe. The iframe imports a script that uses promises. The script is transpiled to be compatible with ie11 but when I run it in ie11 it crashes at the promise.

I tried running the same polyfill script as I do in index.html but it crashed (at some url-checking part) so I'm thinking that I should either re-write that script to make it not crash in the iframe. But maybe someone knows of another way of sharing all the polyfills with the iframe?


Solution

  • It is not possible to pass JavaScript functions, classes, variables or prototypes into iframes due to security. An iframe can however access the parent's window but not the other way around. The HTML in the iframe would need to have the polyfills directly in it.