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

docs(react-live-dynamic): reduces 32.2% size of the docs website #4451

Merged
merged 7 commits into from
Jul 27, 2021

Conversation

tomchentw
Copy link
Contributor

📝 Description

Load live-editor dynamically after page mount

Per page size reduction: 785kB -> 532kB. Reduced 32.2% of the initial bytes.

out

⛳️ Current behavior (updates)

The current <CodeBlock /> imports react-live everywhere. Even for those pages that are not even using the live-editor feature (live=true ).

🚀 New behavior

Refactor <CodeBlock /> and make the live-editor parts loadable via next/dynamic.

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

The loadable information by Nextjs:

loadable

@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2021

⚠️ No Changeset found

Latest commit: ccff167

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

@vercel
Copy link

vercel bot commented Jul 24, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/chakra-ui/chakra-ui/HxHBMXHFetpSNvLScnKBoSSR7EiB
✅ Preview: https://chakra-ui-git-fork-tomchentw-docs-react-live-dynamic-chakra-ui.vercel.app

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ccff167:

Sandbox Source
create-react-app-ts Configuration

Copy link
Contributor

@with-heart with-heart left a comment

Choose a reason for hiding this comment

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

That's an impressive amount of improvement for how little change is required. Thanks so much!


function CodeBlock(props) {
const [isMounted, { on }] = useBoolean()
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL, again! I forgot this was even a thing 🤦

if (render) {
if (isMounted && render) {
/**
* @TODO Not sure if this is even used?
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I seems cannot find the source of it from the MDX docs

@segunadebayo segunadebayo changed the title Docs/react-live-dynamic. Reduces 32.2% size of the docs website docs(react-live-dynamic): reduces 32.2% size of the docs website Jul 27, 2021
@segunadebayo segunadebayo merged commit 362d029 into chakra-ui:main Jul 27, 2021
@tomchentw tomchentw deleted the docs/react-live-dynamic branch July 31, 2021 05:41
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.

4 participants