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

reduce .next/static/chunks to 🔥 33% (according swr-site) #1463

Merged
merged 9 commits into from Feb 24, 2023
Merged

Conversation

dimaMachina
Copy link
Collaborator

@dimaMachina dimaMachina commented Feb 3, 2023

I was able to reduce .next/static/chunks to 33% (with a comparison of main branch) or to 16.21% according to previous PR #1448

image

size of .next/static/chunks

main previous pr this pr
4060262 3247164 2720631
  • import *.css/ theme layout / theme config files in _app.mdx
  • auto create _app.mdx if missing cc @promer94
  • add some tests to ensure we tree shake some unneeded data
  • ✅ fixed getDynamicMeta

I still have error while running next build sometimes, didn't found why it happens
image

@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2023

⚠️ No Changeset found

Latest commit: d33d259

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 changesets to release 7 packages
Name Type
nextra Major
nextra-theme-blog Major
nextra-theme-docs Major
example-blog Patch
example-docs Patch
swr-site Patch
docs Patch

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 Feb 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
nextra-theme-docs-dev ❌ Failed (Inspect) Feb 24, 2023 at 2:38PM (UTC)
nextra-v2 ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 24, 2023 at 2:38PM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
nextra ⬜️ Ignored (Inspect) Feb 24, 2023 at 2:38PM (UTC)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 171.89 KB (🔴 +85.79 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

One Hundred Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/404 7.01 KB 178.9 KB 51.11% (🟢 -24.35%)
/500 7 KB 178.89 KB 51.11% (🟢 -24.35%)
/about/a-page.en-US 6.97 KB 178.86 KB 51.10% (🟢 -24.36%)
/about/acknowledgement.en-US 6.96 KB 178.85 KB 51.10% (🟢 -24.36%)
/about/team.en-US 7.01 KB 178.9 KB 51.11% (🟢 -24.35%)
/blog.en-US 7.58 KB 179.47 KB 51.28% (🟢 -24.35%)
/blog/swr-v1.en-US 12.46 KB 184.34 KB 52.67% (🟢 -24.34%)
/blog/swr-v1.ru 14.13 KB 186.02 KB 53.15% (🟢 -24.35%)
/docs/404-500.en-US 7.85 KB 179.73 KB 51.35% (🟢 -24.35%)
/docs/advanced.en-US 7.34 KB 179.22 KB 51.21% (🟢 -24.36%)
/docs/advanced/cache.en-US 19.13 KB 191.01 KB 54.57% (🟢 -24.38%)
/docs/advanced/cache.ru 20.37 KB 192.25 KB 54.93% (🟢 -24.39%)
/docs/advanced/code-highlighting.en-US 7.8 KB 179.69 KB 51.34% (🟢 -24.36%)
/docs/advanced/dynamic-markdown-import.en-US 8.56 KB 180.45 KB 51.56% (🟢 -24.36%)
/docs/advanced/file-name.with.DOTS.en-US 7.01 KB 178.9 KB 51.11% (🟢 -24.36%)
/docs/advanced/file-name.with.DOTS.es-ES 7.03 KB 178.91 KB 51.12% (🟢 -24.37%)
/docs/advanced/file-name.with.DOTS.ru 7.08 KB 178.96 KB 51.13% (🟢 -24.35%)
/docs/advanced/images.en-US 7.25 KB 179.14 KB 51.18% (🟢 -24.35%)
/docs/advanced/markdown-import.en-US 11.3 KB 183.19 KB 52.34% (🟢 -24.36%)
/docs/advanced/more/loooooooooooooooooooong-title.en-US 7.06 KB 178.95 KB 51.13% (🟢 -24.36%)
/docs/advanced/more/tree/one.en-US 7.02 KB 178.91 KB 51.12% (🟢 -24.36%)
/docs/advanced/more/tree/three.en-US 6.97 KB 178.85 KB 51.10% (🟢 -24.36%)
/docs/advanced/more/tree/two.en-US 7.02 KB 178.91 KB 51.12% (🟢 -24.36%)
/docs/advanced/performance.en-US 9.29 KB 181.17 KB 51.76% (🟢 -24.36%)
/docs/advanced/performance.es-ES 9.46 KB 181.35 KB 51.81% (🟢 -24.36%)
/docs/advanced/performance.ru 10.1 KB 181.98 KB 51.99% (🟢 -24.35%)
/docs/advanced/react-native.en-US 8.87 KB 180.75 KB 51.64% (🟢 -24.35%)
/docs/advanced/react-native.ru 9.44 KB 181.33 KB 51.81% (🟢 -24.35%)
/docs/advanced/scrollbar-x.en-US 7.99 KB 179.87 KB 51.39% (🟢 -24.36%)
/docs/arguments.en-US 8.08 KB 179.97 KB 51.42% (🟢 -24.36%)
/docs/arguments.es-ES 8.15 KB 180.04 KB 51.44% (🟢 -24.36%)
/docs/arguments.ru 8.41 KB 180.29 KB 51.51% (🟢 -24.35%)
/docs/callout.en-US 7.13 KB 179.02 KB 51.15% (🟢 -24.36%)
/docs/change-log.en-US 7.33 KB 179.22 KB 51.20% (🟢 -24.35%)
/docs/change-log.es-ES 12.78 KB 184.67 KB 52.76% (🟢 -24.35%)
/docs/change-log.ru 12.89 KB 184.78 KB 52.79% (🟢 -24.34%)
/docs/code-block-without-language.en-US 7.16 KB 179.05 KB 51.16% (🟢 -24.36%)
/docs/conditional-fetching.en-US 7.95 KB 179.84 KB 51.38% (🟢 -24.36%)
/docs/conditional-fetching.es-ES 8.01 KB 179.89 KB 51.40% (🟢 -24.36%)
/docs/conditional-fetching.ru 8.24 KB 180.12 KB 51.46% (🟢 -24.34%)
/docs/data-fetching.en-US 8.35 KB 180.23 KB 51.50% (🟢 -24.35%)
/docs/data-fetching.es-ES 8.4 KB 180.29 KB 51.51% (🟢 -24.35%)
/docs/data-fetching.ru 8.7 KB 180.59 KB 51.60% (🟢 -24.34%)
/docs/error-handling.en-US 9.16 KB 181.05 KB 51.73% (🟢 -24.36%)
/docs/error-handling.es-ES 9.31 KB 181.19 KB 51.77% (🟢 -24.36%)
/docs/error-handling.ru 9.88 KB 181.76 KB 51.93% (🟢 -24.35%)
/docs/getting-started.en-US 14.16 KB 186.05 KB 53.16% (🟢 -24.36%)
/docs/getting-started.es-ES 14.18 KB 186.07 KB 53.16% (🟢 -24.36%)
/docs/getting-started.ru 14.81 KB 186.7 KB 53.34% (🟢 -24.36%)
/docs/global-configuration.en-US 8.24 KB 180.13 KB 51.46% (🟢 -24.35%)
/docs/global-configuration.es-ES 8.3 KB 180.18 KB 51.48% (🟢 -24.36%)
/docs/global-configuration.ru 8.6 KB 180.49 KB 51.57% (🟢 -24.35%)
/docs/middleware.en-US 9.84 KB 181.73 KB 51.92% (🟢 -24.37%)
/docs/middleware.ru 10.65 KB 182.53 KB 52.15% (🟢 -24.37%)
/docs/mutation.en-US 9.73 KB 181.61 KB 51.89% (🟢 -24.37%)
/docs/mutation.es-ES 9.81 KB 181.69 KB 51.91% (🟢 -24.37%)
/docs/mutation.ru 10.49 KB 182.38 KB 52.11% (🟢 -24.37%)
/docs/options.en-US 8.78 KB 180.66 KB 51.62% (🟢 -24.35%)
/docs/options.es-ES 8.93 KB 180.82 KB 51.66% (🟢 -24.35%)
/docs/options.ru 9.53 KB 181.42 KB 51.83% (🟢 -24.34%)
/docs/pagination.en-US 19.16 KB 191.04 KB 54.58% (🟢 -24.39%)
/docs/pagination.es-ES 19.51 KB 191.4 KB 54.68% (🟢 -24.38%)
/docs/pagination.ru 20.4 KB 192.29 KB 54.94% (🟢 -24.39%)
/docs/prefetching.en-US 8.41 KB 180.29 KB 51.51% (🟢 -24.35%)
/docs/prefetching.es-ES 8.49 KB 180.38 KB 51.54% (🟢 -24.35%)
/docs/prefetching.ru 8.91 KB 180.79 KB 51.66% (🟢 -24.35%)
/docs/raw-layout.en-US 7.69 KB 179.57 KB 51.31% (🟢 -24.36%)
/docs/revalidation.en-US 13.44 KB 185.33 KB 52.95% (🟢 -24.34%)
/docs/revalidation.es-ES 13.58 KB 185.47 KB 52.99% (🟢 -24.34%)
/docs/revalidation.ru 14.17 KB 186.06 KB 53.16% (🟢 -24.33%)
/docs/suspense.en-US 8.45 KB 180.34 KB 51.52% (🟢 -24.35%)
/docs/suspense.es-ES 8.51 KB 180.39 KB 51.54% (🟢 -24.35%)
/docs/suspense.ru 8.86 KB 180.75 KB 51.64% (🟢 -24.34%)
/docs/typescript.en-US 8.73 KB 180.62 KB 51.61% (🟢 -24.37%)
/docs/understanding.en-US 14.53 KB 186.42 KB 53.26% (🟢 -24.34%)
/docs/understanding.es-ES 14.53 KB 186.42 KB 53.26% (🟢 -24.34%)
/docs/understanding.ru 14.53 KB 186.42 KB 53.26% (🟢 -24.34%)
/docs/with-nextjs.en-US 8.53 KB 180.41 KB 51.55% (🟢 -24.36%)
/docs/with-nextjs.es-ES 8.66 KB 180.54 KB 51.58% (🟢 -24.35%)
/docs/with-nextjs.ru 9.04 KB 180.93 KB 51.69% (🟢 -24.34%)
/docs/wrap-toc-items.en-US 7.79 KB 179.67 KB 51.33% (🟢 -24.36%)
/docs/wrap-toc-items.es-ES 7.78 KB 179.67 KB 51.33% (🟢 -24.36%)
/docs/wrap-toc-items.ru 7.78 KB 179.67 KB 51.33% (🟢 -24.36%)
/examples/auth.en-US 7.24 KB 179.13 KB 51.18% (🟢 -24.35%)
/examples/auth.es-ES 7.25 KB 179.13 KB 51.18% (🟢 -24.35%)
/examples/auth.ru 7.28 KB 179.16 KB 51.19% (🟢 -24.35%)
/examples/basic.en-US 7.24 KB 179.13 KB 51.18% (🟢 -24.35%)
/examples/basic.es-ES 7.24 KB 179.13 KB 51.18% (🟢 -24.35%)
/examples/basic.ru 7.29 KB 179.17 KB 51.19% (🟢 -24.35%)
/examples/error-handling.en-US 7.25 KB 179.14 KB 51.18% (🟢 -24.35%)
/examples/error-handling.es-ES 7.25 KB 179.14 KB 51.18% (🟢 -24.35%)
/examples/error-handling.ru 7.28 KB 179.17 KB 51.19% (🟢 -24.35%)
/examples/full.en-US 7.23 KB 179.11 KB 51.17% (🟢 -24.35%)
/examples/infinite-loading.en-US 7.26 KB 179.15 KB 51.18% (🟢 -24.35%)
/examples/infinite-loading.es-ES 7.26 KB 179.15 KB 51.19% (🟢 -24.36%)
/examples/infinite-loading.ru 7.31 KB 179.19 KB 51.20% (🟢 -24.35%)
/examples/ssr.en-US 7.25 KB 179.14 KB 51.18% (🟢 -24.35%)
/examples/ssr.ru 7.25 KB 179.13 KB 51.18% (🟢 -24.35%)
/index.en-US 10.99 KB 182.88 KB 52.25% (🟢 -24.36%)
/index.es-ES 10.77 KB 182.65 KB 52.19% (🟢 -24.36%)
/index.ru 11.16 KB 183.05 KB 52.30% (🟢 -24.38%)
/remote/[slug] 6.94 KB 178.83 KB 51.09% (🟢 -24.36%)
/remote/graphql-eslint/[[...slug]] 6.99 KB 178.88 KB 51.11% (🟢 -24.36%)
/remote/graphql-yoga/[[...slug]] 7 KB 178.89 KB 51.11% (🟢 -24.36%)
/test.en-US 7.21 KB 179.1 KB 51.17% (🟢 -24.35%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@dimaMachina dimaMachina merged commit 7e90066 into _app Feb 24, 2023
@dimaMachina dimaMachina deleted the _app2 branch February 24, 2023 14:38
dimaMachina added a commit that referenced this pull request Feb 24, 2023
…c/chunks` size (#1448)

* fix

* extract collect-files to separate file

* fix tests

* changeset

* to have less line changes

* more clear comment

* yet another fix

* fix

* try

* try

* try

* reduce `.next/static/chunks` to 🔥 33% (according `swr-site`) (#1463)

* reduce `.next/static/chunks` for 40%

* autocreate _app.mdx

* remove unneded spaces

* polish

* add tests for getDynamicMeta

* tests

* more tests

* fix getDynamicData

* Apply suggestions from code review
tatukoivisto pushed a commit to tatukoivisto/nextra that referenced this pull request Aug 20, 2023
…c/chunks` size (shuding#1448)

* fix

* extract collect-files to separate file

* fix tests

* changeset

* to have less line changes

* more clear comment

* yet another fix

* fix

* try

* try

* try

* reduce `.next/static/chunks` to 🔥 33% (according `swr-site`) (shuding#1463)

* reduce `.next/static/chunks` for 40%

* autocreate _app.mdx

* remove unneded spaces

* polish

* add tests for getDynamicMeta

* tests

* more tests

* fix getDynamicData

* Apply suggestions from code review
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.

None yet

1 participant