Solution skill
Shrink the optimizely-sdk bundle with v6 or the lite import
Complete solution
Shows how to fix shrink the optimizely-sdk bundle with v6 or the lite import. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Lodash and promises were removed in v4, but v5 grew again with ODP. Maintainers shipped v6 with a modular API that supports tree-shaking of unused components like OdpManager, significantly cutting bundle size.
Steps
- Issue optimizely/javascript-sdk#352 (closed, 11 comments): the distributed SDK was large (lodash, promise polyfill, then ODP and ua-parser-js in v5). Lodash and promises were removed in v4, but v5 grew again with ODP. Maintainers shipped v6 with a modular API that supports tree-shaking of unused components like OdpManager, significantly cutting bundle size.
- If the SDK bundle is too big, upgrade to v6, which has a modular API so bundlers can tree-shake unused pieces like OdpManager. On v5, import from @optimizely/optimizely-sdk/lite for edge-style deploys to skip the heavier modules, and disable ODP via odpOptions { disabled: true } if you dont use it, since ODP pulls in ua-parser-js.
When to use
You are seeing this: Issue optimizely/javascript-sdk#352 (closed, 11 comments): the distributed SDK was large (lodash, promise polyfill, then ODP and ua-parser-js in v5). Use this skill when you run into "Shrink the optimizely-sdk bundle with v6 or the lite import".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/optimizely/javascript-sdk/issues/352
Evidence
In https://github.com/optimizely/javascript-sdk/issues/352, the reporter asked: Issue optimizely/javascript-sdk#352 (closed, 11 comments): the distributed SDK was large (lodash, promise polyfill, then ODP and ua-parser-js in v5). Lodash and promises were removed in v4, but v5 grew again with ODP. Maintainers shipped v6 with a modular API that supports tree-shaking of unused components like OdpManager, significantly cutting bundle size. The verified answer: If the SDK bundle is too big, upgrade to v6, which has a modular API so bundlers can tree-shake unused pieces like OdpManager. On v5, import from @optimizely/optimizely-sdk/lite for edge-style deploys to skip the heavier modules, and disable ODP via odpOptions { disabled: true } if you dont use it, since ODP pulls in ua-parser-js. Source thread: https://github.com/optimizely/javascript-sdk/issues/352
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_TWRS6VpLKSb3lzERdkghdQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Shrink the optimizely-sdk bundle with v6 or the lite import <span>— Vectle</span></a>