Skip to content

Block Infrastructure: allow building blocks separately #17099

Closed

Description

@jeherve

Jetpack product discussion

  • pedMtX-RS-p2

Background

Jetpack blocks are currently tightly bound to one another:

  • The JavaScript on the editor's side is bundled into a single js bundle, in _inc/blocks.
  • The tools used to register, enqueue JavaScript, and manage blocks on the frontend all live in one class, Jetpack_Gutenberg.
  • Some blocks rely on other classes that ship with the Jetpack plugin: Jetpack_AMP_Support, Jetpack_Options, Jetpack, and for some blocks some classes created specifically for those blocks: Jetpack_Mapbox_Helper and Jetpack_Instagram_Gallery_Helper come to mind.
  • Some blocks rely on custom REST API endpoints, living under _inc/lib/core-api/wpcom-endpoints/.

Those blocks were also created before WordPress 5.8 and its new block registration process were introduced:
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/

Ideally, we would want to switch to this new block registration process for a few reasons:

  • It would allow splitting some of those blocks into standalone plugins if necessary.
  • It allow splitting each block's dependencies, thus only loading what is necessary when only some blocks are available on a site.
  • It would surface the blocks in the plugin description in the WordPress.org plugin directory, thus helping site owners discover what blocks are at their disposal.

Obviously, switching from one big JavaScript bundle with all blocks and their dependencies to multiple files can have a negative impact on performance. This problem may be addressed with some changes in Gutenberg.

Async block loading in Gutenberg

There has been an effort in the Gutenberg project to change the way blocks are loaded, allowing third-party plugins to load multiple blocks without impacting the block editor performance. This project is tracked here:

Tasklist

### Tasks
- [ ] https://github.com/Automattic/jetpack/issues/32408
- [ ] https://github.com/Automattic/jetpack/issues/32602
- [ ] Block Infra: async block asset loading #32069
- [ ] https://github.com/Automattic/jetpack/pull/32256
- [ ] https://github.com/Automattic/jetpack/pull/32388
- [ ] https://github.com/Automattic/jetpack/issues/34120

Requirements (old project)

Note
The requirements below were originally set for a first attempt at this project back in 2021. They do not apply anymore today.

In order to be able to ship some of those blocks as standalone blocks, without the need for the full Jetpack plugin, we'd need to make a few changes:


Past Jetpack Product discussions

  • p9dueE-1VR-p2
  • p9dueE-1BH-p2

Async communication

#jetpack-blocks-improvements
#gutenberg-async-loading-code-splitting

Activity

  1. added
    EnhancementChanges to an existing feature — removing, adding, or changing parts of it
    EpicFormerly "Primary Issue", or "Master Issue"
    [Focus] BlocksIssues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack
    on Sep 8, 2020
  2. self-assigned this
    on Sep 8, 2020
  3. kbrown9 commented on Dec 7, 2020

    @kbrown9
    Member

    Update textdomains for standalone blocks, maybe as a post-install composer script, part of the jetpack-blocks package.

    I opened a proposal PR #18003 for using the wp-textdomain npm package to change composer package strings. I wonder if that would also be useful for the blocks work. Let me know if you have any comments on that approach!

  4. moved this from To triage to To do in Jetpack Blocks [Archived]on Aug 7, 2023
  5. removed their assignment
    on Aug 10, 2023
  6. 3 remaining items

  7. added
    [Plugin] JetpackIssues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
    and removed on Aug 10, 2023
  8. changed the title [-]Blocks: allow building blocks separately[/-] [+]Block Infrastructure: allow building blocks separately[/+] on Aug 10, 2023
  9. moved this from In Progress to Blocked/On Hold in Jetpack Blocks [Archived]on Aug 16, 2023
  10. kraftbj commented on Aug 16, 2023

    @kraftbj
    Contributor

    Once the individual block.json files are present and able to provide visibility, we'll put this project on hold while Gutenberg works on the async asset loading solution.

  11. self-assigned this
    on Nov 8, 2023
  12. kraftbj commented on Sep 19, 2024

    @kraftbj
    Contributor

    I'm going to close this issue since we've done as much as we can until async block loading is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EnhancementChanges to an existing feature — removing, adding, or changing parts of itEpicFormerly "Primary Issue", or "Master Issue"[Focus] BlocksIssues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack[Package] Blocks[Plugin] JetpackIssues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/[Pri] Normal[Status] Blocked / Hold

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions