Skip to content

Conversation

@hiteshshetty-dev
Copy link
Contributor

Description
This PR implements performance improvements and optimizations for the example site. The changes include dynamic imports for better bundle splitting, improved accessibility.

Example

Before:

  • Single monolithic example page with all components loaded upfront
  • Build size:
Sample Page Sizes before analyze/client before
  • Lighthouse score:
Lighthouse report before

After:

  • Individual dynamic pages with code splitting
  • Build size:
Sample Page Sizes after analyze/client after
  • Lighthouse source
Lighthouse report before

Context
The example site was experiencing performance issues due to loading all example components upfront on each route, which created large bundle sizes and slow initial page loads. Additionally, the older version of @faker-js/faker (v8.2.0) was not supporting tree-shaking, significantly increasing the build size.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Sep 6, 2025

⚠️ No Changeset found

Latest commit: c7721af

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could still be done using a single [example].tsx file, mapping the example name to the dynamic import path, page title and description, couldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! You're absolutely right that a single [example].tsx file could handle this with a mapping approach.
I initially implemented it that way, but then explored individual pages thinking it would provide better bundle optimization. However, after your comment, I realize the performance benefits might not be as significant as I initially thought, especially since we're already using dynamic imports.
I'd be happy to revert to the single [example].tsx approach - it would definitely be cleaner and easier to maintain. The main optimization we achieved (moving the common layout to _app.tsx) would still be preserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Additional context: The benefit of moving the layout to _app.tsx is that it gets included in the initial HTML, and only the RTE examples would be loaded dynamically. This should provide a better user experience with faster initial page loads.

Before:
before moving layout to _app.tsx
After:
after moving layout to _app.tsx

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! I think keeping the [example].tsx would be better. Since these are just examples, code simplicity is more important than performance, and having a single pair of TSX and JSX files per example would help with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I’ve reverted the changes to [example].tsx

@hiteshshetty-dev hiteshshetty-dev force-pushed the example-site-perf-improvement branch from 85edfb4 to 98023d9 Compare September 10, 2025 17:46
Comment on lines 95 to 119
const EXAMPLES = [
['Android Tests', 'android-tests'],
['Checklists', 'check-lists'],
['Code Highlighting', 'code-highlighting'],
['Custom Placeholder', 'custom-placeholder'],
['Editable Voids', 'editable-voids'],
['Embeds', 'embeds'],
['Forced Layout', 'forced-layout'],
['Hovering Toolbar', 'hovering-toolbar'],
['Huge Document', 'huge-document'],
['Images', 'images'],
['Inlines', 'inlines'],
['Markdown Preview', 'markdown-preview'],
['Markdown Shortcuts', 'markdown-shortcuts'],
['Mentions', 'mentions'],
['Paste HTML', 'paste-html'],
['Plain Text', 'plaintext'],
['Read-only', 'read-only'],
['Rendering in iframes', 'iframe'],
['Rich Text', 'richtext'],
['Search Highlighting', 'search-highlighting'],
['Shadow DOM', 'shadow-dom'],
['Styling', 'styling'],
['Tables', 'tables'],
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an easy way of deduplicating this list with the one in [example].tsx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I missed this while migrating changes to ExampleLayout. I’ve now created a constants file with all the examples listed there, and both Layout and [example].tsx now use the same file

@dylans dylans merged commit d2344ea into ianstormtaylor:main Sep 23, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants