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

Custom Partial Plotly Bundle to Reduce Bundle Size Further #135

Closed
mithi opened this issue Jul 30, 2020 · 8 comments
Closed

Custom Partial Plotly Bundle to Reduce Bundle Size Further #135

mithi opened this issue Jul 30, 2020 · 8 comments

Comments

@mithi
Copy link
Owner

mithi commented Jul 30, 2020

Full discussion in: plotly/plotly.js#5031

@mithi mithi added the help wanted Extra attention is needed label Jul 30, 2020
@mithi
Copy link
Owner Author

mithi commented Jul 30, 2020

Screen Shot 2020-07-31 at 12 50 53 AM

@mithi
Copy link
Owner Author

mithi commented Jul 30, 2020

Attempting to reduce bundle size further
#55

@mithi
Copy link
Owner Author

mithi commented Jul 30, 2020

Base

Screen Shot 2020-07-31 at 2 07 34 AM

After using custom bundle

import Plotly from "plotly.js/lib/core";
import Scatter3d from "plotly.js/lib/scatter3d"
import Mesh3d from "plotly.js/lib/mesh3d"

import createPlotlyComponent from "react-plotly.js/factory";
Plotly.register([Scatter3d, Mesh3d]);

const CustomPlotly = createPlotlyComponent(Plotly);
export default CustomPlotly;

Screen Shot 2020-07-31 at 1 59 52 AM

After splitting custom bundle

Screen Shot 2020-07-31 at 4 57 38 PM

When you split the core plotly module from others

        import("plotly.js/lib/core").then(Plotly => {
            Plotly.register([Scatter3d, Mesh3d])
            this.Plot = createPlotlyComponent(Plotly)
        })

@mithi mithi removed the help wanted Extra attention is needed label Jul 30, 2020
@mithi mithi changed the title Custom Partial Plotly Bundle Not Working Custom Partial Plotly Bundle to Reduce Bundle Size Further Jul 30, 2020
@mithi
Copy link
Owner Author

mithi commented Jul 31, 2020

Base

Screen Shot 2020-07-31 at 2 04 05 AM

Custom Bundle

Screen Shot 2020-07-31 at 1 56 32 PM

Custom Bundle Split

89007002-7bfd8e80-d33a-11ea-9712-805a4a537ffa

@mithi
Copy link
Owner Author

mithi commented Jul 31, 2020

This is the result of splitting to two bundles 312.71 KB and 115.61 KB

Screen Shot 2020-07-31 at 5 59 56 PM Screen Shot 2020-07-31 at 5 51 32 PM
. .

@mithi
Copy link
Owner Author

mithi commented Jul 31, 2020

With a 414kb bundle this is the performance

Screen Shot 2020-07-31 at 4 26 48 PM Screen Shot 2020-07-31 at 4 27 46 PM
. .

With 450kb bundle this is the performance

Screen Shot 2020-07-31 at 6 11 12 PM Screen Shot 2020-07-31 at 6 14 14 PM
. .

@mithi
Copy link
Owner Author

mithi commented Jul 31, 2020

Netlify Performance (450kb)

Screen Shot 2020-07-31 at 6 21 10 PM Screen Shot 2020-07-31 at 6 22 06 PM Screen Shot 2020-07-31 at 6 23 21 PM
. . .

Netlify Custom Split Bundle Performance (300kb + 115kb)

Screen Shot 2020-07-31 at 6 52 33 PM Screen Shot 2020-07-31 at 6 56 26 PM Screen Shot 2020-07-31 at 6 47 43 PM
. . .

@mithi
Copy link
Owner Author

mithi commented Nov 5, 2020

The best way to reduce bundle size is to use a smaller library such as
https://github.com/mithi/bare-minimum-3d

@mithi mithi closed this as completed Nov 5, 2020
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

No branches or pull requests

1 participant