-
Notifications
You must be signed in to change notification settings - Fork 2k
Remove the window.AppBoot function #98543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~22 bytes removed 📉 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning shared in the description makes sense and so do the changes. I did some smoke testing via calypso.live and everything seems to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsnajdr did you find a reliable way to trigger the window.AppBoot
error locally so we can test whether this solves the issue?
It happens to me all the time locally, whenever there is a hot-update that is not a mere React component handled by React Refresh. In that sense, I can reliably trigger it 🙂 Before merging this, I'd like to change the way how the chunks are now represented in the HTML page. When you go to
I'd like to move the Reader chunks to be instead:
because that's what we want: preload the Reader chunks so that when the router handles the The reason why I want preload is that the Cc: @sgomes who probably has existing experience with |
Hey @jsnajdr! 👋 I can give some advice on Generally, One way to mitigate this would be to add The really really interesting option would be to switch to native modules, though 🙂 If we had access to dynamic |
This is exactly what we have here. We load the page( '/read', async () => {
await import( 'reader' );
next();
}, ... );
page.start(); We know that Until now we've been loading the
Oh, that would be very nice! And easier to implement than in Gutenberg, which has too many compatibility constraints. |
Oh, sorry, I misunderstood what you meant! I didn't realise that you were referring to two stages within the same navigation. Yes, in that case, Once again,
The biggest constraint tends to be the same-origin policy, but I don't think that's an issue in this case. |
@sgomes Yes, they are a mere optimization / progressive enhancement. If the preload didn't happen at all, then webpack runtime would load all the chunks anyway. They just won't be preloaded. I'm implementing this in #98799. |
ccd1ac4
to
fcfbf48
Compare
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
All the prererequisites for this PR are done:
Now it's time to merge also this one 🙂 |
Awesome! Let's p2 about this one, @jsnajdr! Just so folks are aware of what we did, and if anyone hits into similar issues as they change branches, they would report to us. |
I'm often running into the dreadful "
window.AppBoot
is not a function error" so I started looking into it.This PR is the result: let's remove the
window.AppBoot
function and replace it with amain
/boot
function that is called directly in the JS code. That's how webpack apps are supposed to be done. Webpack will make sure that the chunks are loaded in the last one, and that the root module which callsmain()
is run only when all other modules are loaded.I'm not sure about two things:
home
orreader
). These chunks are loaded after the entrypoint. But the scripts will be executed only aftermain()
was already called, because that call is in the entrypoint chunk. Before this PR, we postponed themain
call until all chunks were loaded.