widgetti / widgetti/ipyvuetify

lazy loading heavyweight dependencies in lab

Open
#212 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
355
Forks
61
PR merge metrics
No merged PRs in 30d

Description

thanks for ipyvuetify!

Problem

The core ipyvuetify bundles are very large (~1.8mb), and appear to block the load of the Lab application (e.g. when the "three moon" animation starts)... this is better than the bad old days where it would just make webpack fail, but still not a great experience.

Motivation

Over on jupyterlite, we've been tightening up the performance story, and use our docs site as a stress test. We include ipyvuetify, we've shaved off enough from the core that we're now starting to see extensions in our top-five blockers.

Proposed Solution

A quick fix for this is to use a lazy loading approach for the exports key. Basically, this would move the import of index.js into an async function, along with the theme side-effect. It may also require changing some webpack settings.

The one challenge is getting the version, which can't be lazy loaded: it may be sensible to split that, or accept having it captured in two places and adding a test to keep them in sync.

The bottom line trade will be a slight delay when the first widget this package provides is rendered, which is usually far less noticeable, as it's less likely the browser will be loading much else other than some websocket messages, vs start up time when likely hundreds of files are vying for a spot in the loading queue.

Related

Here's some prior art for adopting this approach from core, and other heavyweight plugins:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in js/src/labplugin.js at the exports key, then compare the lazy-loading patterns in the linked ipywidgets, bqplot, pythreejs, and plotly examples. Check how index.js, the theme side effect, version handling, and webpack settings interact. Done means heavyweight widget code loads on first use without blocking Lab startup, with version consistency covered by a test if it is duplicated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system, frontend, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.