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

[Doc] Explain how to lazy load <richTextInput> #9263

Merged
merged 2 commits into from
Sep 8, 2023
Merged

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Sep 8, 2023

The <RichTextInput> component depends on TipTap, which in turns depends on ProseMirror. Together, these libraries represent about 120kB of minified JavaScript. If you don't use <RichTextInput> on all your forms, you can lazy load it to reduce the size of your bundle.

To do so, replace the import:

import { RichTextInput } from 'ra-input-rich-text';

with a dynamic import:

const RichTextInput = React.lazy(() =>
    import('ra-input-rich-text').then(module => ({
        default: module.RichTextInput,
    }))
);

Once compiled, your application will load the <RichTextInput> only when needed.

@djhi djhi added this to the 4.14.1 milestone Sep 8, 2023
@djhi djhi merged commit 4aea914 into master Sep 8, 2023
9 checks passed
@djhi djhi deleted the doc-lazy-load-richtext branch September 8, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants