You need to enable JavaScript to run this app. Angular生产AOT模式应用加载空白、预加载器失效及网络空闲耗时排查
优惠活动
大模型
产品
解决方案
定价
更多

Angular生产AOT模式应用加载空白、预加载器失效及网络空闲耗时排查

生产环境AOT编译Angular应用加载异常

问题描述

  • 采用AOT编译的生产模式Angular应用,完整加载总耗时为7-8秒,该时长属于正常加载区间
  • 加载期间整屏持续为空白状态:已配置的应用预加载器本应在应用加载完成前展示,但实际未正常渲染,用户体验较差
  • 已启用gzip压缩配置,压缩后main*.js产物文件大小低于400kb
  • 网络性能排查时发现,加载流程中存在约4000ms的空闲间隔,间隔期间无资源请求,暂不清楚问题处理方向

排查参考材料

  • 待排查站点地址:https://ayushmanbhava.org
  • 性能问题排查截图:https://i.sstatic.net/m8LSb.png

参考代码片段

以下为项目当前的AppModule配置代码:

export function HttpLoaderFactory(httpClient: HttpClient) {
  return new TranslateHttpLoader(httpClient);
}

export function initializeApp(appInitService: AppInitService) {
  return (): Promise<any> => { 
    return appInitService.Init();
  }
}

const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
  suppressScrollX: true
};

@NgModule({
  imports: [
    HttpModule,
    BrowserModule,
    BrowserAnimationsModule,
    SharedModule,
    HttpClientModule,
    PerfectScrollbarModule,
    NgxPermissionsModule.forRoot(),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
      }
    }),
    InMemoryWebApiModule.forRoot(InMemoryDataService, { passThruUnknownUrl: true }),
    RouterModule.forRoot(rootRouterConfig, { useHash: false })
  ],
  declarations: [AppComponent],
  providers: [
    { provide: PERFECT_SCROLLBAR_CONFIG, useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG },
    { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
    { provide: APP_INITIALIZER, useFactory: initializeApp, deps: [AppInitService], multi: true},
    fakeBackendProvider,
    AuthenticationService, CommonService, AuthGuard, AdminGuard, CookieService,
    Globals, UserService, PubService, CartService, AppInitService,
    {provide: LocationStrategy, useClass: PathLocationStrategy}
  ],
  bootstrap: [AppComponent],
  entryComponents: []
})
export class AppModule { }

内容的提问来源于stack exchange,提问作者Jay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.06 19:24:09