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
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
- 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
This commit is contained in:
1 parent
a8b6e65831
commit
e2356954ef
5 files changed
+39
-32
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { APP_INITIALIZER, InjectionToken } from '@angular/core';
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { environment } from '../../environments/environment';
|
||||
@@ -16,15 +16,19 @@ const _appConfig: AppConfig = {
|
||||
apiBaseUrl: environment.apiBaseUrl,
|
||||
};
|
||||
|
||||
export function appConfigFactory(http: HttpClient) {
|
||||
return (): Promise<void> => {
|
||||
return lastValueFrom(http.get<AppConfig>('config.json')).then(
|
||||
(config) => { Object.assign(_appConfig, config); },
|
||||
() => {
|
||||
// Keep defaults if config.json is not available (dev mode).
|
||||
},
|
||||
);
|
||||
};
|
||||
/**
|
||||
* Load runtime config.json asynchronously AFTER the app boots.
|
||||
* Replaces the former APP_INITIALIZER that blocked the initial render.
|
||||
* This way the page renders immediately with environment defaults, then
|
||||
* patches in the runtime API URL once it arrives.
|
||||
*/
|
||||
export function loadAppConfigAsync(http: HttpClient): Promise<void> {
|
||||
return lastValueFrom(http.get<AppConfig>('config.json')).then(
|
||||
(config) => { Object.assign(_appConfig, config); },
|
||||
() => {
|
||||
// Keep defaults if config.json is not available (dev mode).
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export const appConfigProvider = {
|
||||
@@ -32,12 +36,12 @@ export const appConfigProvider = {
|
||||
useValue: _appConfig,
|
||||
};
|
||||
|
||||
export const appConfigInitProvider = {
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: appConfigFactory,
|
||||
deps: [HttpClient],
|
||||
multi: true,
|
||||
};
|
||||
/**
|
||||
* @deprecated The APP_INITIALIZER is no longer registered by default.
|
||||
* The `loadAppConfigAsync` function is called directly from `app.config.ts`
|
||||
* in a non-blocking way. This export is kept for backward compatibility only.
|
||||
*/
|
||||
export const appConfigInitProvider = null;
|
||||
|
||||
export function getAppConfig(): AppConfig {
|
||||
return _appConfig;
|
||||
|
||||
@@ -6,7 +6,10 @@ import { StationConfig } from '../interfaces/station-config';
|
||||
import { getAppConfig } from './app-config.service';
|
||||
import { ThemeService } from './theme.service';
|
||||
|
||||
/** Hardcoded defaults — used when the API is unavailable (dev fallback). */
|
||||
/**
|
||||
* Hardcoded defaults — used when the API is unavailable (dev fallback).
|
||||
* Rendered immediately on the initial paint so the page is never blank.
|
||||
*/
|
||||
const DEFAULT_CONFIG: StationConfig = {
|
||||
id: 0,
|
||||
key: 'default',
|
||||
|
||||
Reference in new issue
Block a user