platform-browser vs. platform-browser-dynamic
2025-05-29
Written by: tdtc
The difference between platform-browser-dynamic and platform-browser is the way your Angular app will be compiled.
Using the dynamic platform makes Angular send the just-in-time compiler to the front-end along with your application.
Which means your application is being compiled client-side.
On the other hand, using platform-browser leads to an ahead-of-time pre-compiled version of your application being sent to the browser.
Which usually means a significantly smaller package is sent to the browser.
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true,
})
.catch(err => console.error(err));
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './app/app-module';
platformBrowser().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true,
})
.catch(err => console.error(err));
When the offline template compiler is used, platform-browser-dynamic isn’t necessary because all reflective access and metadata are converted to generated code.