April 2026
To understand why this distinction matters, we first need to understand what a webpage actually is at runtime.
Before comparing extensions and injected scripts, we need to understand what they are actually modifying. Without this, the difference between them looks almost identical — but it is not.
When a browser loads a page, it:
At this point, the key idea is:
That structure is what we call the DOM — and it becomes the shared surface that all scripts interact with.
Now that this is clear, we can understand what extensions and injected scripts are actually competing over.
Once the DOM exists, different actors can interact with it — but not all in the same way.
That difference in execution context is what determines power, access, and risk.
Extensions run in a separate, sandboxed environment controlled by the browser.
This means they exist “next to” the page rather than inside it.
They can:
But they cannot:
Injected scripts work very differently.
Instead of operating from the outside, they execute inside the page’s own JavaScript context.
This means they are no longer observers — they are participants.
This allows them to:
At this point, the distinction becomes meaningful:
Extensions are isolated by design. Injected scripts are not.
Extensions interact with the DOM. Injected scripts interact with execution logic.
The closer you get to execution logic, the more control — and potential misuse — becomes possible.
Now that the architecture is clear, the following demo shows the difference in practice.
A simple web page with internal logic — observe what each approach can actually modify.
Counter: 0
As you interact with the demo, a clear pattern emerges:
And importantly — both still appear to be “just JavaScript,” even though they operate in fundamentally different contexts.
Understanding this separation is essential for understanding modern browser architecture — from ad blockers to automation tools.