feat(seo): Phase 3 — preload LCP image and reduce APP_INITIALIZER blocking #8

Merged
kfj001 merged 1 commits from feat/seo-phase3-optimizations into main 2026-08-06 21:08:52 -07:00
Member

Summary

Implements Phase 3 of the SEO audit recommendations — rendering architecture optimizations that improve initial paint speed and Core Web Vitals.

Changes

1. Preload LCP Image (src/index.html)

  • Added <link rel="preload" as="image" href="svg/mountain-landscape.svg"> for the hero background image
  • The hero background is the Largest Contentful Paint (LCP) element on the landing page
  • Preloading ensures the browser fetches it early, reducing LCP time
  • Uses the default SVG as a fallback; runtime station config replaces it after hydration

2. Reduce APP_INITIALIZER Blocking (src/app/app.config.ts, src/app/app.ts)

  • Removed blocking APP_INITIALIZER providers for config.json and station config
  • Config loads now fire asynchronously in App.ngOnInit() (browser platform only)
  • During SSR/prerender, the page renders instantly with default config — no network wait
  • This means crawlers get a fully rendered page without waiting for API responses

Impact

  • SSR/prerender: Build emits default-content HTML instantly — no HTTP calls during route extraction
  • SEO: Search crawlers see a fully rendered page without waiting for network
  • LCP: Hero background image paints faster because JS starts sooner
  • TTFB: Initial paint no longer blocked by config.json or station-config API calls

Testing

  • Build succeeds with both browser and server bundles
  • All 54 unit tests pass
  • Prerendered output confirmed for all 5 public routes
  • Preload tag present in prerendered HTML output
## Summary Implements Phase 3 of the SEO audit recommendations — rendering architecture optimizations that improve initial paint speed and Core Web Vitals. ### Changes #### 1. Preload LCP Image (src/index.html) - Added `<link rel="preload" as="image" href="svg/mountain-landscape.svg">` for the hero background image - The hero background is the Largest Contentful Paint (LCP) element on the landing page - Preloading ensures the browser fetches it early, reducing LCP time - Uses the default SVG as a fallback; runtime station config replaces it after hydration #### 2. Reduce APP_INITIALIZER Blocking (src/app/app.config.ts, src/app/app.ts) - Removed blocking `APP_INITIALIZER` providers for config.json and station config - Config loads now fire asynchronously in `App.ngOnInit()` (browser platform only) - During SSR/prerender, the page renders instantly with default config — no network wait - This means crawlers get a fully rendered page without waiting for API responses ### Impact - **SSR/prerender**: Build emits default-content HTML instantly — no HTTP calls during route extraction - **SEO**: Search crawlers see a fully rendered page without waiting for network - **LCP**: Hero background image paints faster because JS starts sooner - **TTFB**: Initial paint no longer blocked by config.json or station-config API calls ### Testing - Build succeeds with both browser and server bundles - All 54 unit tests pass - Prerendered output confirmed for all 5 public routes - Preload tag present in prerendered HTML output
robot added 7 commits 2026-08-06 14:36:03 -07:00
feat: add SSR and prerendering support
CI Pipeline / backend-test (push) Successful in 10m24s
CI Pipeline / frontend-test (push) Failing after 19s
CI Pipeline / frontend-build (push) Failing after 23s
CI Pipeline / backend-lint (push) Successful in 12s
CI Pipeline / backend-test (pull_request) Successful in 10m45s
CI Pipeline / frontend-test (pull_request) Failing after 20s
CI Pipeline / frontend-build (pull_request) Failing after 12s
CI Pipeline / backend-lint (pull_request) Successful in 13s
CI Pipeline / quality-gate (push) Successful in 3s
CI Pipeline / quality-gate (pull_request) Successful in 3s
a783626f34
- Install @angular/ssr and @angular/platform-server (v21.2.x)
- Create server entry point (server.ts) and server bootstrap (main.server.ts)
- Add server routes config (app.server.routes.ts) with 5 prerendered routes:
  /, /about, /schedule, /events, /contact
- Update angular.json with server/ssr/prerender build configuration
- Add prerender-routes.txt for build-time static route generation
- Fix SSR compatibility:
  - App component: guard DOM access with isPlatformBrowser
  - StructuredDataComponent: skip head manipulation on server
  - ThemeService: skip CSS variable application on server
  - ShowService/EventService: return empty arrays on API failure
    (graceful fallback during prerender with no backend)
- Prerendered output verified: 5 static HTML routes in dist/
fix(tests): load JIT compiler before router imports in seo.service.spec
CI Pipeline / backend-test (push) Successful in 14m20s
CI Pipeline / frontend-test (push) Failing after 14s
CI Pipeline / frontend-build (push) Failing after 10s
CI Pipeline / backend-lint (push) Successful in 10s
CI Pipeline / backend-test (pull_request) Successful in 11m56s
CI Pipeline / frontend-test (pull_request) Failing after 22s
CI Pipeline / frontend-build (pull_request) Failing after 19s
CI Pipeline / quality-gate (pull_request) Successful in 3s
CI Pipeline / backend-lint (pull_request) Successful in 11s
CI Pipeline / quality-gate (push) Successful in 3s
0bde1cfc75
The PlatformLocation static initializer in @angular/common/router
requires @angular/compiler to be loaded first. Move the compiler
import before any Angular router/common imports so the JIT facade
is available when the module loads.
fix: align @angular/platform-server and @angular/ssr versions with Angular core
CI Pipeline / backend-test (push) Successful in 11m37s
CI Pipeline / frontend-test (push) Successful in 37s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 10s
CI Pipeline / backend-test (pull_request) Successful in 11m59s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 33s
CI Pipeline / backend-lint (pull_request) Successful in 12s
CI Pipeline / quality-gate (push) Successful in 3s
CI Pipeline / quality-gate (pull_request) Successful in 3s
2d26269c1a
The SSR packages were pinned to ^21.2.19 and ^21.2.20 which had
strict peer dependency requirements conflicting with @angular/common
at ^21.2.0. This caused npm ci (used in CI) to fail with peer
dependency resolution errors.

Aligned both packages to ^21.2.0 to match the rest of the Angular
core packages, and regenerated package-lock.json.
fix(ssr): apply theme CSS vars during SSR and enable client hydration
CI Pipeline / backend-test (push) Successful in 9m4s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 14s
CI Pipeline / backend-test (pull_request) Successful in 9m17s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 10s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
e95a158d57
- ThemeService: remove isPlatformBrowser guard so CSS custom properties
  are applied during SSR/prerender — server-rendered HTML now carries the
  correct color scheme and gradients (fixes missing colors on test site).

- main.ts: add provideClientHydration() so Angular preserves the server-
  rendered DOM on the client instead of destroying and rebuilding it
  (fixes jarring full-page reload between static and dynamic versions).

- Tests: update theme.service.spec.ts to match new behaviour, expand
  coverage with gradient tests and empty-value handling (9 tests).
  Fix structured-data.component.spec.ts import paths. All 54 tests pass.
fix(ssr): remove broken dynamic import and lazy-init engine
CI Pipeline / backend-test (push) Successful in 5m39s
CI Pipeline / frontend-test (push) Successful in 27s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / backend-test (pull_request) Successful in 5m24s
CI Pipeline / frontend-test (pull_request) Successful in 22s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
CI Pipeline / backend-lint (pull_request) Successful in 8s
63bc2fb22d
- Replace await import('./main.server.js') with lazy getEngine()
  (original path was wrong — main.server.ts lives in src/, not root)
- AngularNodeAppEngine handles manifest registration internally;
  no manual bootstrap import needed
- Add npm scripts: build:ssr, build:prerender, serve:ssr:radio-station
- Add PRERENDER.md build documentation

Verified: clean build prerenders all 5 routes, 54 tests pass
fix(ssr): enable static route rendering and fix self-import in server.ts
CI Pipeline / backend-test (push) Successful in 9m12s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / backend-test (pull_request) Successful in 10m0s
CI Pipeline / frontend-test (pull_request) Successful in 23s
CI Pipeline / frontend-build (pull_request) Successful in 30s
CI Pipeline / backend-lint (pull_request) Successful in 9s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
a8b6e65831
- Add AngularAppEngine.ɵallowStaticRouteRender flag so the engine serves
  prerendered static HTML from disk instead of falling back to SSR
- Rename default export to named const (requestHandler) to avoid self-import
  loop when the module is the entry point
- Use requestHandler directly in the main-module listener instead of
  importing './server.js' which caused TS2307 resolution failure
feat(seo): Phase 3 — preload LCP image and reduce APP_INITIALIZER blocking
CI Pipeline / backend-test (push) Successful in 10m9s
CI Pipeline / frontend-build (push) Successful in 30s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / frontend-test (push) Successful in 30s
CI Pipeline / backend-test (pull_request) Successful in 10m30s
CI Pipeline / frontend-test (pull_request) Successful in 25s
CI Pipeline / frontend-build (pull_request) Successful in 41s
CI Pipeline / backend-lint (pull_request) Successful in 9s
CI Pipeline / quality-gate (push) Successful in 3s
CI Pipeline / quality-gate (pull_request) Successful in 3s
e2356954ef
- Add <link rel="preload"> for hero background image (LCP element) in index.html
- Remove blocking APP_INITIALIZER for config.json and station config loading
- Config loads now fire asynchronously in App.ngOnInit() (browser only)
- SSR/prerender renders instantly with default config — no network wait
- Improves LCP, Time to First Byte, and initial paint for SEO
kfj001 approved these changes 2026-08-06 21:08:46 -07:00
kfj001 merged commit 2ece38e52d into main 2026-08-06 21:08:52 -07:00
kfj001 deleted branch feat/seo-phase3-optimizations 2026-08-06 21:08:52 -07:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: WesternTechnologies/kmtnflower#8