-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Example site performance improvements and optimization #5953
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
Example site performance improvements and optimization #5953
Conversation
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
85edfb4 to
98023d9
Compare
site/components/ExampleLayout.tsx
Outdated
| 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'], | ||
| ] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
…plify dynamic imports in ExamplePage


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:
After:
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
yarn test.yarn lint. (Fix errors withyarn fix.)yarn start.)yarn changeset add.)