Further optimize initial page load by leveraging preboot#1760
Further optimize initial page load by leveraging preboot#1760ybnd wants to merge 9 commits intoDSpace:mainfrom
Conversation
preboot is triggered when the app first becomes stable, which caused the app to hang once CSR started Tracked the issue down to initialization - GoogleAnalyticsService.addTrackingIdToPage() - AuthService.trackTokenExpiration()
SSR HTML inlines CSS into style.ng-transition elements. By default, Angular removes these as soon as CSR starts. Because preboot buffers CSR off-screen, the SSR HTML remains visible during the transition - without CSS. This workaround strips the ng-transition attribute from SSR styles so they aren't removed automatically and subsequently removes these same styles once preboot is finished.
On the server, @slideSidebarPadding always resolved to 'expanded' because slideSidebarOver did not emit true
…imize-initial-page-load-by-leveraging-preboot
|
This pull request has been automatically marked as stale because it has not had Allowing pull requests to close as stale helps us filter out old work that is no longer All pull requests closed by this bot act like normal pull requests; If these changes are still relevant then please comment and/or rebase your PR based on the |
|
We are currently looking to solve some performance issues around page loading times and got notified because the PR was marked as |
|
@tinsch I expect we'd have to more or less start from scratch at this point... The
For what it's worth, this PR and #1761 were mostly looking at smoothness and perceived performance. |
|
@ybnd : If this approach is no longer relevant, should we close this PR (and possibly also #1761 and #1733)? While I very much appreciate the work you did here to try out some optimizations, if this work isn't relevant anymore, I'd lean towards closing the work. Even if closed, we can always revisit these PRs at a time in the future if there is useful information to be had. |
That was more or less why I had kept them around as drafts I think, but looking back it would be more clear if they're closed. |
References
Description
This PR introduces Angular
prebootas a next step in improving initial page load performance in production mode.The main improvement in this PR concerns the transition from server-side to client-side rendered HTML on lazily-loaded pages (e.g.
/search,/items/...etc.)Instead of blanking out the page while it is being replaced,
prebootbuffers the CSR page in the background while the SSR page is still visible and only replaces it once the app is completely done loadingThis results in significantly smoother page loads
Changes:
Added
prebootFixed some minor compatibility issues between DSpace and preboot
ApplicationRef.isStablemore reliable (preboot depends on it)Fixed some minor bugs with the navbar search box & admin sidebar
Added an animation to make it more clear when the application is still loading. IMO this can help a lot with understanding that e.g. events may not come through
More of a proof-of-concept for now, feedback is greatly appreciated!
Caveats / further work:
prebootcurrently doesn't support Angular 13 without a workaround that hasn't been merged yetprebootitselfprebootis to capture interaction events on the SSR page and replay them once the CSR page is loaded. However, fully integrating this would require more time. See Enable preboot event replay for shorter apparent TTI #1761 for more information.Instructions for Reviewers
Compare initial load perfomance in production mode between this PR and current
mainin different browsersStart from a blank page
Open any lazily-loaded DSpace page (try this for multiple pages, while logged in and not)
/search?q=.../communities/...Do the same on https://demo7.dspace.org/home and compare for "smoothness"
In the current build, the page will blank out for a moment while rendering.
This PR should significantly improve this
Currently there is a glitch when loading or refreshing pages while already logged in; the SSR page accounts for the admin sidebar as if it was pinned, while it can't be.
This PR should eliminate this bug.
Hard refresh the page and compare in the same way. Note that the "feel" can be quite different between these two cases -- when loading from a blank page the flashing tends to be more noticeable
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
yarn run lintpackage.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.