-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mixpanel-browser is huge! Maybe support tree shaking? What can be done? #128
Comments
@jbwyme @ilyakamens @tdumitrescu any thoughts on the size of the package? is there any way we can decrease the size in the build step? |
Totally in support of making the package size smaller. The mixpanel js library comes bundled with support for a number of different features like in-app notifications which bloats out the size. However, we should be able to restructure it a bit so that you can do more granular imports when using |
@jbwyme awesome, thank you! It would be great to have a core package for mixpanel, and then extras like in-app notifications could be separate packages. i like the way lodash does this, where a single helper function is packaged. |
Thanks everyone for looking at doing that! @baldwmic I actually disagree with the packages approach. This approach is kind of outdated and was replaced even in In import get from 'lodash/get';
import remove from 'lodash/remove';
import isPlainObject from 'lodash/isPlainObject'; This way you don't need to go ahead and install each package and get your import X from 'mixpanel-browser/X'; I would suggest going with that option. Tree shakingIn today's js frontend world, support for tree shaking is a must. import X from 'mixpanel-browser/X';
import Y from 'mixpanel-browser/Y';
import Z from 'mixpanel-browser/Z'; I could do: import { X, Y, Z } from 'mixpanel-browser'; tree shaking is really easy to have along side with commonjs support and it's just some babel configurations to add. You can take a look at IMO having both WDYT? :) |
ooh @kazazor i do like the idea of installing only one package and then just modifying the import statements, good point! that does seem much easier from a developer perspective. i also agree that tree-shaking would be awesome! removing code that is not used will definitely help decrease the size of developer builds :) |
Note that if your main concern is just reducing download size on pageload, then the CommonJS and other bundled/synchronous versions of the lib will never be as efficient as the standard snippet-loaded version (where you just add the embed code to your page). In that version, just the small minified embed code runs initially, and the rest of the lib is downloaded asynchronously without blocking, and will also be more cacheable than if it is included in the main bundle of an application. |
@tdumitrescu How about the idea of a mixpanel-lite package, which only contains say the code for tracking events, or something along those lines? |
@tdumitrescu the problem with "installing" a package by embedding a script tag in html is that it's not very maintainable for our application. My team, and I'd be willing to bet many others, prefer to use |
Yes, there would definitely be advantages to improving the modularization of the lib and building separate versions with different parts included. Until we find the time to implement it (or shepherd through an acceptable pull request), I was suggesting the embed code as a way to remove the pageload impact of the extra 40K gzipped bundle. @baldwmic you can totally use npm/yarn to install |
@tdumitrescu To elaborate on your earlier message: Note that if your main concern is just reducing download size on pageload, then the CommonJS and other bundled/synchronous versions of the lib will never be as efficient as the standard snippet-loaded version (where you just add the embed code to your page). In that version, just the small minified embed code runs initially, and the rest of the lib is downloaded asynchronously without blocking, and will also be more cacheable than if it is included in the main bundle of an application. Our main concern is JS execution time. Larger JS payloads, even if they're cached by the browser, impart a pretty significant first-pass performance penalty. (V8 can't do any optimizations on the first pass + parsing + JIT compilation) see https://medium.com/reloading/javascript-start-up-performance-69200f43b201 for more info. |
@matthewoates sure, parsing a larger blob of js will take more time before the Mixpanel lib starts firing off events, no doubt about that. My point about using the embed code is that parsing the lib in that case does not block pageload (it loads the lib asynchronously, and any |
I think one good first step is defining what browsers should this library support. |
Created a PR to decrease its size #143 |
I use this library solely for sending events, and paying 70kB for that is hard to swallow. Is there any progress on repackaging using a more modular structure? |
@bradleyayers I created a branch that is intended for logging only (we also use it only for logging). |
Any update here would be highly appreciated |
Unfortunately, the only update at the moment is that this ask hasn't reached high priority in our product backlog. If you simply need to avoid blocking pageload with your JS loading, then the script tag embed code loader is the way to go (i.e. the "standard" mixpanel-js installation). For static bundles including mixpanel-browser via require/import, the amount of effort relative to the gains (your bundle will be a few kb smaller gzipped) simply hasn't yet justified prioritizing this over other engineering projects. |
@tdumitrescu Totally fair, we switched to using the js library instead. Thank you. |
The size is really frustrating. I still hope there will be updates. |
Also could a non-build source file be exposed from the Similarly I don't see any reason for having inline styles being included with a library that is suppose to just track users. If these could be part of a special build just for when they are needed that would make a lot more sense. |
@Swaagie which builder are you looking to support, or more to the point what exact entry would you like in
There is a plan to support alternative builds so you can drop modules that you don't use, but unfortunately no ETA right now on when we'll be able to work on it. |
More granular functionality importing would definitely be nice. Hopefully this can help in migration toward this goal. It also introduces a no-notifications bundle as a stop-gap measure: |
I think using dynamic import help this I made the util of the dynamic load of the mixpanel and util components for React user here It uses dynamic-import syntax, that is in a ECMAScript proposal and not currently part of the language standard. if you use babel you need |
Any progress here? 40k is way too huge for simply tracking |
Any news? Mixpanel lib is almost the same size than react-dom... seriously? We are on our way to stop mixpanel because of this |
any updates? The purpose of mixpanel is to ultimately enhance user experience. Long initial loading times directly contribute to worse UX. It follows that decreasing bundle size should be mixpanels #1 priority imo. |
It has been almost 2 years since I opened this issue. I'm afraid it seems to not be Mixpanel's priority at all even that this issue has a LOT of people interesting in. Seems like if anyone would like it to be reduced the only way it's going to be is by using something else than Mixpanel :/ |
I've been following this issue since a couple years ago and it's quite clear to me this company doesn't give a dam. Just move to another solution, there are dozens of solutions like mixpanel out there. It's a shame they let random developers create a minimal version of this from their own pocket. Mixpanel is not a free product/solution. We have stopped using and the only big deal about it was the large payload we stopped serving ;) |
This is disappointing. We are reviewing the 'lite' package to see if it feels safe to use. @john-doherty thank you for that, we are betting the future of our product on these analytics... so we will need to vet it a bit. I intend to notify Mixpanel about this as well. |
Although we are only calling Mixpanel on the client-side in our application, it still is bundled server-side where it does this check for |
Same for me, it's 23% of my app size while I just use basic parts of the SDK... After 4 years, any plans to fix this fast??? We will have to drop Mixpanel otherwise, please do something...! |
@dawsbot I'm using next.js, whether or not you use Mixpanel's Library, or the lighter library, you need to load it dynamically client side. My technique was to assign the script's loaded event to a redux/react state, then initialize Mixpanel inside of |
@bradgreens No worries, I fully removed mixpanel last month. The lightest bundle size option out there 😜 |
Agreed. The response time for this issue is unacceptable. I've moved over to amplitude. (edit: and not just for this reason) |
@matthewoates Not gonna lie, it's kind of painful to see Atlassian on Amplitude's homepage. But that said, alternative options are very much in play. We harvested some great metrics, but the developer confidence just isn't available on this project. |
Hey folks, I just wanted to let you all know that this library will be much smaller in Q1 2022. With the deprecation of messaging, we will be able to remove some sizable portions of the code base. If the size at that point is still an issue to you, we will work with you to get to a good solution. |
I am assigning this issue to myself right now to make sure it is, at long last, resolved. I'm embarrassed it's taken this long and promise you we'll fix it. |
Hey! Still on track? Is it out maybe and can share a link here? Thanks! |
@odedsolutions the release removing the in-app notifications code will be publicly available likely this coming week. |
Fantastic, thanks!
Thanks for picking up this issue after such a long stale period!
…On Mon, Feb 7, 2022 at 12:54 AM teddddd ***@***.***> wrote:
@odedsolutions <https://github.com/odedsolutions> the release removing
the in-app notifications code will be publicly available likely this coming
week.
—
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATUMQRTNKGNPMWXWSQ5TGQDUZ33Z5ANCNFSM4DGNGHUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
is this released? |
Hi @tdumitrescu, is there a a new timeline for releasing this? It's been nearly 2 weeks. |
The new release (v2.45.0) is now available everywhere. |
given the size of this bundle is there a recommended pattern for lazy loading in Next.js applications? |
Last I recall they chipped at the size, but if it’s still an issue just load it like any other bullshit script way after your primary UX loads. |
+1 this issue is not resolved, v2.45.0 is still 60kb+. Quite a shame |
5 years with zero progress, I will use mixpanel-lite as well... |
same problem with big size here |
This works well for us, it removes mixpanel-browser from the pages/_app chunk that is part of the first load js shared by all through dynamically importing it.
|
Why is the issue closed? The weight is still too big |
Hi everyone,
I hope it's ok writing out of the blue, last I don't usually send these out
and hope it's not too disturbing :)
I need help with my latest endeavor - AI Game Master - an immersive
text-based role playing game for iOS and Android.
Create unique characters, explore thrilling quests, fight fierce enemies -
all through written text and tons of imagination. With AI generated images
and natural sounding narration, indulge in an epic adventure right in your
pocket!
We're live TODAY on Product Hunt, and would highly appreciate your support:
*https://www.producthunt.com/posts/ai-game-master-dungeon-rpg*
<https://www.producthunt.com/posts/ai-game-master-dungeon-rpg>
(sign up and vote please 🙏🏻)
You are more than welcome to try the game, and see why everyone is falling
in love with it. (Speakers on preferably 🤗 )
https://apps.apple.com/us/app/ai-game-master-dungeon-rpg/id6475002750
https://play.google.com/store/apps/details?id=com.aisuccess.ai_game_master
Thank you for your support throughout these years in all my
journeys 🙏🏻 It is not taken for granted ❤️
Hope you are well!
Best regards,
Oded
|
Still, 50kb gzipped is a relatively huge, is there any workaround? |
According to
webpack-bundle-analyzer
mixpanel-browser
is huge!This is the one of the biggest vendor packages we have and it doesn't make any sense to me.
To put it into perspective, this is
moment.js
:This is even bigger tan
moment
, andmoment
is big!I'm opening a discussion here with Mixpanel guys, how can we make it smaller?
can we support ES6 modules style in order to leverage tree shaking?
Any other ideas?
The text was updated successfully, but these errors were encountered: