Skip to content
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

This library is large #65

Open
mariusandra opened this issue Jul 6, 2020 · 8 comments
Open

This library is large #65

mariusandra opened this issue Jul 6, 2020 · 8 comments

Comments

@mariusandra
Copy link
Collaborator

As it stands now, posthog-js v1.3.0 is about 52.4kb of minified code.

image

While nowhere near as bad as some of our competitors (mixpanel-browser is 95KB and segment's analytics.js is 187KB), this can still be improved upon.

Should we improve on this and with what priority? We've covered the low hanging fruit and the next step is to refactor and modernise the library's internals. This would greatly help writing proper tests as well.

@boldtrn
Copy link

boldtrn commented Nov 27, 2020

I was wondering, would it be possible to "split" this package. For example if I don't need some of the features. I for example don't need the Toolbar or Session Recording at the moment. That could help to minimize the size for people who only need a part of the features.

@Tbhesswebber
Copy link

I think this stream of work likely would be beneficial to start prioritizing... We just upgraded from 1.13.13 to 1.17.3 and it essentially added 2k to what webpack bundle analyzer is reporting for the g-zipped size.

Before:
image

After:
image

@kouliavtsev
Copy link

OMG!

It's growing!

Screenshot 2023-03-31 at 17 11 29

1.3 was 16kb, 1.5 is 30kb.

Is there a way to reduce the bundle size?

@iamnafets
Copy link

This package is huge and leaving us with wondering whether posthog is worthwhile given we're eating very real consequences from Google on mobile LCP. Any updates on this?

@jyotman
Copy link

jyotman commented Sep 27, 2023

Screenshot 2023-09-27 at 9 49 25 PM
Screenshot 2023-09-27 at 9 57 35 PM
Screenshot 2023-09-27 at 9 59 03 PM

It's getting bigger.
+1 for prioritising the size of this library. This is a big consideration for us while choosing Posthog vs something else. Size reduction or a "lite" version would be much appreciated.

PS: the new segment library is 0.5 KB and mixpanel is 20 KB compared to 38 KB for posthog.

@jyotman
Copy link

jyotman commented Sep 27, 2023

Just discovered this - https://github.com/PostHog/posthog-js-lite/tree/master/posthog-web
Happy to see that effort is being made in this direction 🙌

@marandaneto
Copy link
Member

another instance of that https://posthog.com/questions/posthog-js-lite

@pimterry
Copy link

pimterry commented Dec 4, 2024

Very interested in this also, Posthog-js is now the single largest dependency in my Next.js website bundle, which is a bit ridiculous! I'm trying to improve core web vitals and this is hard to justify.

Posthog JS is now larger than react-dom itself (168kb vs 142kb), and it's more than triple the size it was when @mariusandra first opened this issue about it being large.

I've looked at the two alternative suggestions above but they're not suitable. In my case this is a Next.js marketing site, and I really just want to track anonymous page events and a handful of other very notable interactions, that's it. That shouldn't require a huge bundle imo, but it doesn't look like the lite alternatives include:

  • The React integration (manageable but awkward, since it's tiny anyway)
  • Various constructor options I use for simple fully anonymous tracking: person_profiles: 'identified_only', disable_session_recording: true and advanced_disable_decide: true.
    • Looks like session recording isn't in the lite package so that's fine, but decide & identification is, and it's not clear how to disable those.
    • Really just looking for fewer features here though, so I'd hope that'd be possible in a tiny bundle!

A lightweight package for minimal web analytics would be amazing 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants