Skip to content

web: lazy-load code-insights components and `highlight.js`

Administrator requested to merge vb/lazy-load-insights-and-highlight-js into main

Created by: valerybugakov

Context

To make our bundle smaller and reduce the initial loading time of the web application, we can lazy-load heavy dependencies and optional components.

Changes

  • highlight.js modules specific to different languages are now lazy-loaded.
  • code-insights components are lazy-loaded to avoid including d3.js, react-draggable-grid, visx, and src/enterprise/insights into the main bundle.

Results

The main bundle is 18.93% smaller. 132kb gzipped size was cut from the main bundle.

Before After
Screenshot 2021-10-29 at 15 57 21 Screenshot 2021-10-29 at 15 57 09
Screenshot 2021-10-29 at 15 54 42

Further improvements

Closes https://github.com/sourcegraph/sourcegraph/issues/26433.

Merge request reports

Loading