Soon We Can Finally Banish JavaScript to the ShadowRealm
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
The TC39 ShadowRealm proposal (currently at Stage 2.7) introduces a new kind of JavaScript realm designed purely for isolation. Unlike iframes or Web Workers, a ShadowRealm has its own global and built-in objects but shares the host realm's execution thread, avoiding multi-threading complexity. Code evaluated inside a ShadowRealm cannot interfere with the outer realm's global scope, making it useful for clean-room testing, sandboxing third-party libraries, and preventing global scope pollution. The API exposes just two methods: `evaluate` for running string expressions and `importValue` for dynamically importing ES modules into the ShadowRealm. It is not yet in browsers or the ES-262 standard.
