JIT | AOT | Result | |
---|---|---|---|
Application raw size | 2.9MB | 3.3MB | Increase |
Vendors raw size | 2.67MB | 2.38MB | Decrease |
Initial load time | ~6s | ~2s | Significant decrease |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class ThingsEffects { | |
fetchThings$ = createEffect(() => this.actions$.pipe( | |
ofType(ThingsActions.fetchThings), | |
switchMap(() => this.api.things.fetch() | |
.pipe( | |
map((data) => ThingsActions.update(data.items)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize() { | |
if ('serviceWorker' in navigator && 'BroadcastChannel' in window) { | |
// ... | |
// Subscribe to broadcast channel from worker | |
const apiUpdates = new BroadcastChannel(BROADCAST_CHANNEL); | |
apiUpdates.addEventListener('message', (event: any) => { | |
if (event.data.type === CACHE_UPDATED) { | |
const { cacheName, updatedURL } = event.data.payload; | |
this.retrieveAndSendData(cacheName, updatedURL); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
new RegExp('/things$'), | |
new workbox.strategies.StaleWhileRevalidate({ | |
cacheName: 'api-things', | |
plugins: [ | |
new workbox.broadcastUpdate.Plugin({ | |
channelName: 'api-updates', | |
headersToCheck: ['x-checksum'], // Or other headers | |
}), | |
new workbox.expiration.Plugin({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
/^https:\/\/fonts\.googleapis\.com/, | |
new workbox.strategies.StaleWhileRevalidate({ | |
cacheName: 'google-fonts-stylesheets', | |
}) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
new RegExp('/assets/'), | |
new workbox.strategies.CacheFirst({ | |
cacheName: 'assets', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxEntries: 50, | |
maxAgeSeconds: 30 * 24 * 60 * 60, | |
purgeOnQuotaError: true | |
}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class WorkerService { | |
initialize() { | |
if ('serviceWorker' in navigator && 'BroadcastChannel' in window) { | |
// Initialize worker | |
this.getWorkboxInstance() | |
.subscribe((Workbox) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2019-12-28T20:01:28.887Z","extensionVersion":"v3.4.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MUST BE IN THIS ORDER! | |
import 'core-js/es7/reflect'; | |
import 'zone.js/dist/zone'; | |
import { enableProdMode, NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | |
import { UpgradeModule } from '@angular/upgrade/static'; | |
import * as angular from 'angular'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { platformBrowser } from '@angular/platform-browser'; | |
// This file will be available during the compilation | |
import { AppModuleNgFactory } from './app.module.ngfactory'; | |
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory); |