Skip to content

perf: load the editor chunk lazily - #3373

Merged
kulmann merged 2 commits into
mainfrom
perf/lazy-editor-chunk
Sep 17, 2026
Merged

kulmann merged 2 commits into
mainfrom
perf/lazy-editor-chunk

Conversation

@JammingBen

@JammingBen JammingBen commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

The editor chunk (tiptap, prosemirror, highlight.js, marked) was loaded on first paint. It is now only fetched when an editor is actually opened, and it got slightly smaller.

Async loading:

  • add TextEditorViewer, a read-only editor view exported from the web-pkg main entry as an async component. The announcement modal, the files list and space READMEs and the app store details now use it instead of importing the editor directly.
  • the text editor app resolves its route component and Yjs adapter lazily
  • mail loads the compose widget async, admin settings the announcement section

Bundle size:

  • pin highlight.js to one version, lowlight pulled in a second copy

Note that the editor chunk is still around 1 MB (unzipped). We could get it down by a) separating our implementation from the vendor code and b) curating a list of languages we support code highlighting for. Currently, we pull in all common languages from highlight.js. See #3378 for this.

closes #3217

@JammingBen JammingBen self-assigned this Sep 15, 2026
@JammingBen
JammingBen force-pushed the perf/lazy-editor-chunk branch 2 times, most recently from ffc4865 to 0ab9dfc Compare September 15, 2026 08:38
@JammingBen
JammingBen marked this pull request as ready for review September 15, 2026 09:01
@JammingBen
JammingBen added this pull request to stack #3379 September 15, 2026 12:04
try {
await loadEditor()
} catch {
// the component reports the failure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Claude claims that you would need an errorComponent on the async component definition starting in line 24. Otherwise we would render nothing on failure...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's cleaner to let the component handle this instead of having a generic error component that might not fit into the caller component. And generally, this only throws if the network or the bundle itself is broken, so the page is dead either way then.

@JammingBen
JammingBen requested a review from kulmann September 17, 2026 08:55
The editor chunk (tiptap, prosemirror, highlight.js, marked) was loaded on
first paint. It is now only fetched when an editor is actually opened, and it
got smaller.

Async loading:
- add `TextEditorViewer`, a read-only editor view exported from the web-pkg
  main entry as an async component. The announcement modal, the files list
  and space READMEs and the app store details now use it instead of importing
  the editor directly.
- the text editor app resolves its route component and Yjs adapter lazily
- mail loads the compose widget async, admin settings the announcement section

Bundle size:
- pin highlight.js to one version, lowlight pulled in a second copy
@JammingBen
JammingBen force-pushed the perf/lazy-editor-chunk branch from 968c16e to 38b5969 Compare September 17, 2026 08:55
@kulmann
kulmann merged commit 4037f0c into main Sep 17, 2026
31 checks passed
@kulmann
kulmann deleted the perf/lazy-editor-chunk branch September 17, 2026 11:08
@openclouders openclouders mentioned this pull request Sep 17, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make editor component async

2 participants