web: lazy-load `@sentry/browser`
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 theweb
package.
Results
The main bundle is 4.04% smaller.
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