Skip to content

Conversation

@mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented Nov 20, 2025

Describe your changes

Attempt to improve initial load time by reducing dependencies included in entry bundle.

Dependencies removed from entry:

  • moment-timezone: Removed moment usage from App & lazy loaded ArrowTable

  • vega-lite: Lazy load Metric component (already lazy-loaded ArrowVegaLiteChart)

  • react-json-view: Lazy load Json component


Bundle Analysis:

Before (left): 7.64 MB & After (right): 5.11 MB
Entry bundle - start Entry bundle - after part 1

@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 20, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Collaborator Author

mayagbarnes commented Nov 20, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13071/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13071.streamlit.app (☁️ Deploy here if not accessible)

@mayagbarnes mayagbarnes changed the title Remove moment-timezone from entry bundle Reduce entry bundle - Part 1 Nov 20, 2025
@mayagbarnes mayagbarnes changed the title Reduce entry bundle - Part 1 Reduce entry bundle size - Part 1 Nov 20, 2025
@mayagbarnes mayagbarnes added change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR labels Nov 20, 2025 — with Graphite App
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

📉 Significant wheel size change detected

The wheel file size has decreased by 0.40% (threshold: 0.25%)

  • Current PR: 8789.08 KB
  • Latest develop: 8824.80 KB

Please verify that this change is expected.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2025

📉 Significant bundle size change detected

Metric This Branch develop Change (%)
Total (gzip) 8.23 MiB 8.3 MiB -0.81%
Entry (gzip) 1.67 MiB 2.36 MiB -29.49%

Please verify that this change is expected.

📊 View detailed bundle comparison

@mayagbarnes mayagbarnes marked this pull request as ready for review November 24, 2025 19:18
Copilot AI review requested due to automatic review settings November 24, 2025 19:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the entry bundle size by approximately 33% (from 7.64 MB to 5.11 MB) through lazy loading of heavy dependencies and removing moment from the entry point.

Key changes:

  • Replaced moment usage in App.tsx with a new native getScreencastTimestamp() utility function
  • Lazy loaded three components to exclude their heavy dependencies from the entry bundle: ArrowTable (moment-timezone), Metric (vega-lite), and Json (react-json-view)
  • Added comprehensive test coverage for the new timestamp utility function

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/lib/src/util/utils.ts Added getScreencastTimestamp() function to generate timestamps for screencast filenames without moment dependency
frontend/lib/src/util/utils.test.ts Added comprehensive test suite for getScreencastTimestamp() covering edge cases like padding, midnight, and year boundaries
frontend/lib/src/index.ts Exported getScreencastTimestamp and reordered DownloadContext export alphabetically
frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx Converted ArrowTable, Json, and Metric to lazy loaded components to reduce entry bundle size
frontend/app/src/App.tsx Replaced moment().format() with getScreencastTimestamp() for screencast filename generation

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines -77 to 78
import ArrowTable from "~lib/components/elements/ArrowTable"
import DocString from "~lib/components/elements/DocString"
import ExceptionElement from "~lib/components/elements/ExceptionElement"
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: does it make sense to also lazy-load the other elements here in follow-up PRs?

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 still have some testing to do around this to confirm, but will be part of future PR if it moves needle 👍🏼

@mayagbarnes mayagbarnes merged commit a836fc6 into develop Nov 24, 2025
43 checks passed
@mayagbarnes mayagbarnes deleted the reduce-bundle branch November 24, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants