Skip to content
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

Remove the window.AppBoot function #98543

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open

Conversation

jsnajdr
Copy link
Member

@jsnajdr jsnajdr commented Jan 17, 2025

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 a main/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 calls main() is run only when all other modules are loaded.

I'm not sure about two things:

  1. In addition to loading the entrypoint, we also preload chunks for the current section (e.g., home or reader). These chunks are loaded after the entrypoint. But the scripts will be executed only after main() was already called, because that call is in the entrypoint chunk. Before this PR, we postponed the main call until all chunks were loaded.
  2. We might need to revisit @arthur791004's Assets: Fix the order of the chunk files #95748 PR that fixed the order of chunks. The code after this PR is more sensitive about the order.

@jsnajdr jsnajdr requested review from sirreal and tyxla January 17, 2025 13:43
@jsnajdr jsnajdr self-assigned this Jan 17, 2025
@jsnajdr jsnajdr requested review from a team as code owners January 17, 2025 13:43
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 17, 2025
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~44 bytes removed 📉 [gzipped])

name           parsed_size           gzip_size
entry-login          -43 B  (-0.0%)      -24 B  (-0.0%)
entry-stepper        -32 B  (-0.0%)      -15 B  (-0.0%)
entry-main           -21 B  (-0.0%)       -7 B  (-0.0%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Member

@sirreal sirreal left a 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.

Copy link
Member

@tyxla tyxla left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants