Title: Excessive modulepreload Links in Angular 18.0.0-next.4 Affecting Performance Metrics · Issue #27490 · angular/angular-cli · GitHub
Open Graph Title: Excessive modulepreload Links in Angular 18.0.0-next.4 Affecting Performance Metrics · Issue #27490 · angular/angular-cli
X Title: Excessive modulepreload Links in Angular 18.0.0-next.4 Affecting Performance Metrics · Issue #27490 · angular/angular-cli
Description: Which @angular/* package(s) are the source of the bug? platform-server Is this a regression? No Description I recently upgraded my Angular application to version 18.0.0-next.4 and migrated to esbuild and the new integrated SSR. However, ...
Open Graph Description: Which @angular/* package(s) are the source of the bug? platform-server Is this a regression? No Description I recently upgraded my Angular application to version 18.0.0-next.4 and migrated to esbui...
X Description: Which @angular/* package(s) are the source of the bug? platform-server Is this a regression? No Description I recently upgraded my Angular application to version 18.0.0-next.4 and migrated to esbui...
Opengraph URL: https://github.com/angular/angular-cli/issues/27490
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Excessive modulepreload Links in Angular 18.0.0-next.4 Affecting Performance Metrics","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\nplatform-server\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nI recently upgraded my Angular application to version 18.0.0-next.4 and migrated to esbuild and the new integrated SSR. However, I've noticed a significant impact on performance metrics, particularly First Contentful Paint (FCP) and Largest Contentful Paint (LCP), when using the new version.\r\n\r\nUpon further investigation, I found that Angular now splits all JavaScript code into chunks and adds a ```\u003clink rel=\"modulepreload\">``` for each chunk in the ```\u003chead>``` of the page. Although the scripts are loaded asynchronously with [@defer](https://angular.io/api/core/defer) method, the preloaded scripts seem to be affecting the rendering of critical content, delaying FCP and LCP.\r\n\r\nI've conducted tests using Lighthouse, and the results show that removing the modulepreload links improves FCP and LCP metrics. This issue seems to be similar to what was reported in these GitHub discussions:\r\n\r\n[GoogleChrome/lighthouse#11960](https://github.com/GoogleChrome/lighthouse/issues/11960#issuecomment-779049941)\r\n[vitejs/vite#5991](https://github.com/vitejs/vite/issues/5991#issuecomment-1088711936)\r\nIn both discussions, users reported improvements in FCP and LCP metrics after disabling or reducing the number of modulepreload links.\r\n\r\nUnfortunately, I couldn't find a way to selectively disable modulepreload links in Angular 18.0.0-next.4 based on specific use cases. Therefore, I would like to seek clarification and guidance on how to address this issue to improve performance.\r\n\r\n**Steps to Reproduce:**\r\n\r\nUpgrade an Angular application to version 18.0.0-next.4.\r\nEnable SSR and use esbuild.\r\nAnalyze performance metrics using Lighthouse with and without the modulepreload links.\r\nExpected Behavior:\r\nI expect to see improved FCP and LCP metrics when excessive modulepreload links are removed or selectively disabled.\r\n\r\n**Additional Information:**\r\nI have attached screenshots of the Lighthouse test results, showing the impact of modulepreload links on performance metrics.\r\n\r\n**Screenshots:**\r\n\r\nScreenshot 1 - Lighthouse Test with modulepreload links\r\n\r\n\r\n\r\nScreenshot 2 - Lighthouse Test without modulepreload links\r\nPerformed by removing all modulepreload links server side: \r\n```typescript\r\n html = html.replace(\r\n /\u003clink .?rel=\"modulepreload\" .*?href=\"(?\u003chref>.+?\\.js)\".*?>/g,\r\n ''\r\n );\r\n```\r\n\r\n\r\nYour assistance in resolving this issue would be greatly appreciated.\r\n\r\nThank you.\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\n_No response_\r\n\r\n### Please provide the exception or error you saw\r\n\r\n_No response_\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 18.0.0-next.2\r\nNode: 20.11.1\r\nPackage Manager: yarn 1.22.21\r\nOS: win32 x64\r\n\r\nAngular: 18.0.0-next.4\r\n... animations, cdk, common, compiler, compiler-cli, core, forms\r\n... google-maps, language-service, localize, material\r\n... platform-browser, platform-browser-dynamic, platform-server\r\n... router, service-worker\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.1800.0-next.2\r\n@angular-devkit/build-angular 18.0.0-next.2\r\n@angular-devkit/build-optimizer 0.1302.1\r\n@angular-devkit/core 18.0.0-next.2\r\n@angular-devkit/schematics 17.1.2\r\n@angular/cli 18.0.0-next.2\r\n@angular/ssr 18.0.0-next.2\r\n@schematics/angular 18.0.0-next.2\r\nrxjs 7.8.1\r\ntypescript 5.4.5\r\nzone.js 0.14.4\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\n_No response_","author":{"url":"https://github.com/manzonif","@type":"Person","name":"manzonif"},"datePublished":"2024-04-17T12:10:18Z","url":"https://github.com/angular/angular-cli/issues/27490"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9faa4998-bb49-18d5-3b0c-3fc1d5d51c25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A556:ADA9D:366227B:45BF93E:6B01E019 |
| html-safe-nonce | aa361559bc822fa82d198d070afa44b83889434006231a6c689e69c6106837da |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTU2OkFEQTlEOjM2NjIyN0I6NDVCRjkzRTo2QjAxRTAxOSIsInZpc2l0b3JfaWQiOiIxMDgxNjkxMTgyMTcyNjUxNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a3ced51df768d9776e15b4f0e66e8222033ffd384d9592c66ce192d76acf24ba |
| hovercard-subject-tag | issue:2249427871 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/27490/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d146d56f10d4daef55a238a642b69eae62dd7ac40d5e4a4b6508b88f7dfecd9f/angular/angular-cli/issues/27490 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d146d56f10d4daef55a238a642b69eae62dd7ac40d5e4a4b6508b88f7dfecd9f/angular/angular-cli/issues/27490 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? platform-server Is this a regression? No Description I recently upgraded my Angular application to version 18.0.0-next.4 and migrated to esbui... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | manzonif |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width