Issue
The Sentry JavaScript SDK adds weight to my application bundle. I want to reduce how much SDK code ships in production.
Applies To
All SaaS Customers and Self-Hosted Users
JavaScript SDKs
SDK Setup
Resolution
Reduce JavaScript SDK bundle size by shipping only the SDK features you use, tree-shaking optional internal code, and removing unused default integrations.
Import only the features you use. Optional features such as Session Replay, Browser Tracing, and Browser Profiling stay out of the bundle when you do not import and enable them. Details are in the tree shaking documentation.
Tree-shake optional internal SDK code. If you use a Sentry bundler plugin, set
bundleSizeOptimizations(for exampleexcludeDebugStatements: true). If you configure the bundler yourself, replace flags such as__SENTRY_DEBUG__withfalse. Full steps are in the tree shaking documentation.Remove unused default integrations. Filter them in
Sentry.init, or create aClientwith only the integrations you need so unused defaults can be tree-shaken. See removing a default integration and the tree-shaking default integrations section in the tree shaking documentation.Lazy-load pluggable integrations when you need them later, so they do not add to the initial bundle size. See lazy loading integrations.
