- The
iframesandboxattribute has been fully supported by all major browsers since 2014 (caniuse)
Best practice for running user-submitted code in iframes (a la CodeSandbox, ObservableHQ, etc.) is:
- Use the
sandboxattribute - Use the
allow-*values to whitelist things that are needed & safe. - Run the iframed content in a unique subdomain per user account (or narrower). ObservableHQ does this.