widget-ts-cookiecutter icon indicating copy to clipboard operation
widget-ts-cookiecutter copied to clipboard

Defer loading of widget implementation to first usage

Open bollwyvl opened this issue 5 years ago • 6 comments
trafficstars

Thanks for maintaining this!

This adds lazy-loading of the widget implementation, CSS, and dependencies to the Lab plugin. From a cold cache, this trades:

  • increased time from the first "give me an instance widget X" to pixels
  • decreased time-to-moon-animation of every launch of the Lab application itself

The trade gets a bit murkier with cache, but parsing a huge main is also not free, and I suspect this time goes up faster than linearly.

Motivation

I've done this PR on a whole stack of projects, at this point... the arguments are usually for end users encountering fewer webpack issues (from reduced size/file count of vendor~main). I haven't had anybody revert the change, so seems reasonable to promote more broadly. For developers, it makes sourcemaps for the code in question and dependencies snappier, as it's no longer in the titanic main bundle. I have encountered no issues with deduplication.

bollwyvl avatar Nov 21 '20 15:11 bollwyvl

I love it, and plan to do it to the widget libraries I maintain as well. I think you have a similar or open on bqplot, and I'd like to see that merged as well. Thanks!

maartenbreddels avatar Nov 21 '20 21:11 maartenbreddels

Rebased onto the latest master to pick up the new CI.

jtpio avatar Mar 12 '21 10:03 jtpio

I think you have a similar or open on bqplot, and I'd like to see that merged as well.

Probably referring to this PR? https://github.com/bqplot/bqplot/pull/1192

jtpio avatar Mar 12 '21 10:03 jtpio

I like having named chunks for debuggability and_proof_, but yeah it's probably just vanity window dressing.

bollwyvl avatar Mar 17 '21 13:03 bollwyvl

ha, down to +2 −4. c'mon linter! :crossed_fingers:

bollwyvl avatar Mar 17 '21 23:03 bollwyvl

Huzzah :heavy_check_mark: !

bollwyvl avatar Mar 18 '21 00:03 bollwyvl