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

DOP-4208: lazy load OpenAPI component #975

Merged
merged 1 commit into from
Dec 18, 2023
Merged

DOP-4208: lazy load OpenAPI component #975

merged 1 commit into from
Dec 18, 2023

Conversation

seungpark
Copy link
Collaborator

@seungpark seungpark commented Dec 15, 2023

Stories/Links:

DOP-4208

This PR is focused on reducing app bundle size by lazy loading OpenAPI component (which uses redoc as a dependency), as it is used as a single page component (for testing https://mongodb.com/docs/openapi/preview )

Current Behavior:

staged a couple on the same CDN to compare master branch vs test branch:

docs landing
open api preview page on docs landing
cloud docs
docs

Staging Links:

docs landing
openAPI preview page on docs landing
cloud docs
docs

Notes:

  • app bundle size on branch:
    image

vs app bundle size on master
image

as well as bundle b19b3968-67eaf58023f606c6395f.js not being present in test branch (for redoc package)

@seungpark seungpark marked this pull request as ready for review December 15, 2023 17:16
import React, { lazy } from 'react';

const ComponentMap = {
openapi: lazy(() => import('./OpenAPI')),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I included a few other components that should obviously be lazy loaded

If any objections, could revert this change to track the changes in separate ticket

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a good set of components to lazy load together


const ComponentMap = {
openapi: lazy(() => import('./OpenAPI')),
video: lazy(() => import('./Video')),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

const ComponentMap = {
openapi: lazy(() => import('./OpenAPI')),
video: lazy(() => import('./Video')),
instruqt: lazy(() => import('./Instruqt')),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

src/components/ComponentFactoryLazy.js Show resolved Hide resolved
import React, { lazy } from 'react';

const ComponentMap = {
openapi: lazy(() => import('./OpenAPI')),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a good set of components to lazy load together

@seungpark seungpark merged commit 160c3c0 into master Dec 18, 2023
2 checks passed
@seungpark seungpark deleted the DOP-4208 branch December 18, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants