RTICWDT / college-scorecard

College Scorecard
https://collegescorecard.ed.gov/
312 stars 75 forks source link

JS optimization: ditch D3? #988

Open shawnbot opened 9 years ago

shawnbot commented 9 years ago

We're using D3 because I had imagined a bigger role for charts and visualizations on the site, but there isn't much of that going on right now. D3 is great for jQuery-like DOM manipulation, but it's overkill and bloats the browser bundle (see #969). We have options:

  1. Make a custom D3 build with d3-bundler
  2. Ditch D3 altogether, and replace it with something else:
    • jQuery, because everyone knows and/or loves it
    • Ender, because it's smaller and more modular
    • just use vanilla JS and DOM methods, with some iteration helpers

I'm opting for trying out d3-bundler as a first step.

shawnbot commented 8 years ago

I think this will be resolved by #1317. The custom D3 build is much smaller than jQuery or its ilk (Ender, etc.), and provides what I think is a nicer API.

LisaGee commented 8 years ago

Hi @shawbot

Can you help me understand the risk vs. reward of making this change? I’m not sure I fully understand the impact, but in my experience making changes to underlying libraries/framework introduce a bunch of risk and quite often require a full and complete re-test across browsers and devices. I freely admit that I don’t know what D3 is and am also not sure what the goal is of making this change – also known as, what’s the problem we’re trying to solve?

Can you help expand on the risk vs. benefit of this change?

Thanks,

--Lisa

shawnbot commented 8 years ago

@LisaGee what I've done in #1317 is to slim down our build of D3 (which is a sort of jQuery-like library for DOM manipulation with some specific features for data and visualization) to only include the parts that we use. So I've basically resolved not to replace D3, which means not changing any of the site's code and just removing unused library code to make the browser bundle smaller.

I'm pretty confident that the risk is low, and the benefit is an improved experience from faster page loads.

LisaGee commented 8 years ago

Thanks, @shawnbot. Sorry for my ignorance! Appreciate your patience….