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

Upgrade to D3 4.0 Modules #7

Open
curran opened this issue Jun 9, 2016 · 1 comment
Open

Upgrade to D3 4.0 Modules #7

curran opened this issue Jun 9, 2016 · 1 comment

Comments

@curran
Copy link

curran commented Jun 9, 2016

One of the pain points of adopting Scrollgrid in a setting where the code is bundled (e.g. using Browserify or Webpack) is the fact that it depends on D3 3.5.X, but only uses very few of the features of D3.

When var d3 = require("d3"); is bundled, the resulting bundle gets bloated by 340 KB (156KB minified). The original set of features included in D3 v3.5.17 is described in the index file src/d3.js

import "start";
import "compat/";

import "arrays/";
import "behavior/";
import "color/";
import "core/";
import "dsv/";
import "event/";
import "format/";
import "geo/";
import "geom/";
import "interpolate/";
import "layout/";
import "math/";
import "scale/";
import "selection/";
import "svg/";
import "time/";
import "transition/";
import "xhr/";

import "end";

In order to adopt Scrollgrid in my Web application, I ended up creating a custom D3 v3.5.17build that has only the D3 features that Scrollgrid uses. I modified the above index file to read as follows:

import "start";

import "behavior/";
import "core/";
import "event/";
import "selection/";

import "end";

This reduced the size of the D3 bundle to 53KB (37KB minified).


If Scrollgrid were upgraded to depend on the new D3 modules (d3-selection, d3-drag), the bundle size would be smaller without any custom modifications. Is this something you'd consider for Scrollgrid?

@johnkiernander
Copy link
Member

That's useful to know. I'm waiting until d3 v4 is the latest stable release before I move to depend on individual modules, but I will be at that point.

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

2 participants