Skip to content

refactor: reduce bundle size via dead code removal and log shortening#1439

Merged
fadi-george merged 7 commits intomainfrom
fg/size-improvement
Mar 9, 2026
Merged

refactor: reduce bundle size via dead code removal and log shortening#1439
fadi-george merged 7 commits intomainfrom
fg/size-improvement

Conversation

@fadi-george
Copy link
Copy Markdown
Contributor

@fadi-george fadi-george commented Mar 9, 2026

Description

1 Line Summary

Reduce SDK bundle size by removing unused code, simplifying helpers, shortening debug messages, and removing legacy v16 beta worker fallback.

Details

Series of refactors targeting gzipped bundle size:

  • Shortened debug log messages across the codebase
  • Removed unused helper functions (context/helpers.ts deleted, dom.ts simplified)
  • Simplified DOM helper functions
  • Removed v16 beta worker fallback logic from the service worker
  • Updated size-limit thresholds to reflect the savings

Size Limit Changes

Bundle main This branch Diff
OneSignalSDK.page.es6.js 43.69 kB 41.96 kB -1.73 kB (-3.96%)
OneSignalSDK.sw.js 12.701 kB 12.29 kB -0.411 kB (-3.24%)

Net reduction of ~2.14 kB gzipped across the two main bundles.

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Updated existing unit tests to match shortened debug messages. No behavioral changes, only refactoring.

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

N/A, no UI changes.

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets


Made with Cursor


This change is Reviewable

@fadi-george fadi-george merged commit 41de184 into main Mar 9, 2026
3 checks passed
@fadi-george fadi-george deleted the fg/size-improvement branch March 9, 2026 23:21
@github-actions github-actions Bot mentioned this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants