Amplitude-JavaScript icon indicating copy to clipboard operation
Amplitude-JavaScript copied to clipboard

Tree shaking support

Open gugu opened this issue 4 years ago • 4 comments

Summary

For people, who use a subset api Amplitude API loading the whole library is an overhead. We are optimizing the project to make login/registration pages very fast to load and amplitude (unminified, 200kb) currently has size of our whole UI library + React-DOM combined. The only functions we use are logEvent and setUserProperties

Motivations

Lots of libraries (like date-fns or lodash) allow to import specific functions instead of the whole large module

gugu avatar Jun 07 '21 10:06 gugu

Hi there ! Are there any news on this? For the context, we have an npm package that uses amplitude-js to log events from our different front-end projects to our amplitude instance. So a fairly simple usage since we only need in fact the getInstance function. But currently it makes our project weight 233.72KB (16KB without amplitude-js).

Thank you for your response in advance!

JulianRomana avatar Dec 30 '21 09:12 JulianRomana

Hi all, thanks for the suggestion. This is part of our roadmap and we are hoping to support this by early next year.

kevinpagtakhan avatar Dec 30 '21 21:12 kevinpagtakhan

any updates on this? having the same issue

But currently it makes our project weight 233.72KB (16KB without amplitude-js).

PawFV avatar Apr 08 '22 15:04 PawFV

Announcement 📣

Amplitude is introducing a new TypeScript SDK for Browser [BETA]. This new SDK provides improved developer experience, helps users instrument data more seamlessly and provide more control over data being instrumented using custom plugins. The new SDKs also comes with:

  • Browser env support
  • Web worker env support
  • Server-side rendering framework support (ie Next.js)
  • Tree-shaking support
  • Custom plugins
  • Built-in type definitions

To learn more about the new SDK, here are some useful links:

  • NPM: https://www.npmjs.com/package/@amplitude/analytics-browser
  • GitHub: https://github.com/amplitude/Amplitude-TypeScript
  • Documentation: https://developers.amplitude.com/docs/typescript-browser-beta

kevinpagtakhan avatar May 07 '22 00:05 kevinpagtakhan