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

Block Editor: Preload together with Post Editor section #45934

Merged
merged 2 commits into from
Sep 29, 2020

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Sep 25, 2020

Currently, at multiple places, when the user intends to click on a link to open the post editor, we preload the post editor section. That helps with perceived performance, because the section starts loading immediately, and when the user navigates to the post editor, it loads faster because it had already loaded.

However, for many of the users, we use the block editor, and this introduces a couple of problems:

  • We're still preloading the post editor section, which is totally unnecessary for those users because it never gets used.
  • We're not preloading the block editor section, so we're missing out on an opportunity to improve the loading speed.

This PR introduces a common preloader helper that preloads both sections, and updates all the locations that were previously preloading the post editor to preload both sections. That resolves both of the abovementioned problems.

Ideally, we would know which section to preload and would preload only that section, but at this point, I expect the positive impact of preloading both sections to be higher than the negative one.

Changes proposed in this Pull Request

  • Block Editor: Preload together with Post Editor section

Testing instructions

  • Checkout this branch.
  • Go to /posts/:site
  • Open your network tab
  • Roll over a post
  • Verify the gutenberg-editor section chunk gets preloaded.

@tyxla tyxla added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Post/Page Editor The editor for editing posts and pages. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Performance [Goal] Gutenberg Working towards full integration with Gutenberg labels Sep 25, 2020
@tyxla tyxla requested a review from a team September 25, 2020 15:03
@tyxla tyxla requested a review from a team as a code owner September 25, 2020 15:03
@tyxla tyxla self-assigned this Sep 25, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Sep 25, 2020

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

App Entrypoints (~25 bytes added 📈 [gzipped])

name        parsed_size           gzip_size
entry-main       +123 B  (+0.0%)      +25 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~100 bytes removed 📉 [gzipped])

name          parsed_size           gzip_size
posts-custom       -112 B  (-0.0%)      -23 B  (-0.0%)
posts              -112 B  (-0.0%)      -26 B  (-0.0%)
pages               -66 B  (-0.0%)      -27 B  (-0.0%)
reader              -64 B  (-0.0%)      -24 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~63 bytes removed 📉 [gzipped])

name                                         parsed_size           gzip_size
async-load-design-blocks                          -138 B  (-0.0%)      -39 B  (-0.0%)
async-load-components-web-preview-component        -64 B  (-0.0%)      -24 B  (-0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

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.

@tyxla tyxla requested review from jsnajdr and a team September 28, 2020 10:16
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only see gutenberg-editor being loaded.

This branch

Captura de Tela 2020-09-28 às 06 38 58

Production

Captura de Tela 2020-09-28 às 06 39 25

I believe this would be solved by the suggestion I left but I may be confused about the intention.

Comment on lines +6 to +8
export function preloadEditor() {
preload( 'gutenberg-editor' );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function also include preload( 'post-editor' )?

Suggested change
export function preloadEditor() {
preload( 'gutenberg-editor' );
}
export function preloadEditor() {
preload( 'gutenberg-editor' );
preload( 'post-editor' );
}

Copy link
Member Author

@tyxla tyxla Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, sorry @saramarcondes - this is expected behavior.

It was changed because of this review request: #45934 (comment) but I forgot to update the PR description.

Could you take another look?

@tyxla tyxla dismissed sarayourfriend’s stale review September 28, 2020 14:02

I forgot to update PR description and testing instructions, so Sara was following old ones.

@sarayourfriend
Copy link
Contributor

Oh gosh sorry @tyxla I should have read the existing discussion but my mind glossed right over it. I'll dismiss my review and this LGTM and is behaving as expected. The refactor into a single function for preloading the editor is a great idea too, glad you were able to make that improvement.

@tyxla tyxla merged commit 718fa5f into master Sep 29, 2020
@tyxla tyxla deleted the update/preload-editor-add-gutenberg branch September 29, 2020 07:40
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Goal] Gutenberg Working towards full integration with Gutenberg [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Type] Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants