The DOM is the browser’s in-memory tree representation of a document and its elements. Angular templates normally avoid direct DOM manipulation: compilation turns declarative HTML into JavaScript commands that render the interface. section 9.2.3
Angular’s rendering pipeline uses different compilation strategies:
- JIT compilation compiles templates in the browser during development, improving build speed while reducing runtime performance. section 9.2.3
- AOT compilation produces a precompiled production application whose JavaScript renders the UI without HTML templates at runtime. section 9.2.3
- SSR requires care because browser-only DOM APIs such as window are unavailable on the server. section 9.2.3
Deferring browser DOM work in SSR
A scroll-to-top component initially accesses window during initialization and fails under SSR. Wrapping the event registration in afterNextRender defers browser work until rendering completes; ChangeDetectorRef updates visibility after scroll events.







