Skip to content

web: lazy-load `@sentry/browser`

Administrator requested to merge vb/lazy-load-sentry-browser 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 like @sentry/browser.

Changes

  • Added script tag to the app.html that lazy-loads Sentry SDK.
  • Removed @sentry/browser imports (apart from TS types) from the web package.

Results

The main bundle is 4.04% smaller.

Screenshot 2021-11-01 at 15 42 57

Notes

Ad-blocking or script-blocking extensions may prevent Sentry SDK from being fetched and initialized correctly. The solution here would be to use a server-side pass-through for event reporting and our CDN for serving the init script. Created an issue to investigate further: https://github.com/sourcegraph/sourcegraph/issues/26981.

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

Merge request reports

Loading