-
Notifications
You must be signed in to change notification settings - Fork 733
Distributed JS is bloated for no reason #519
Comments
This is super vital for us to continue using Segment. It continues to trump the file size of our entire webpage! Would really like to see some sort of generator that spits out a file with only the desired integrations, or documentation on how to build it properly with a ES6/CommonJS module approach. |
This is being worked on for the hosted version of analytics.js that is served by Segment. The initial challenge here was that analytics.js needs to be custom built with your project's specific set of integrations in realtime to handle requests, and running browserify was too slow to do this in real time (in the order of seconds which is too slow to server HTTP requests in real time). We're trying out a new architecture to enable this. I don't have an ETA, but we should be testing this out with in the upcoming months. |
Being tracked internally at https://segment.atlassian.net/browse/PLATFORM-1661 |
Just to give an update, this has been incrementally rolling out for the past few weeks, and is expected to complete before the holidays. |
This has been rolled out and you should see significantly smaller sizes going forwards. For a test Segment project with 1 client side integrations, here are the new sizes: Note that it's not quite the same as the open source version still because we support a few additional features in the segment hosted version, but we still have some further optimizations we'll be pursuing in the future. |
We currently use Segment with Google Analytics over here at my company.
The current size of analytics.min.js is 380KB which apart from being a significant portion of our page weight, also has a large execution time on slower mobile devices.
Building a custom version of analytics.js with GA integration gives a package of just 104KB which is less than 1/3rd of the 380 KB. But we were wondering why segment's cdn doesn't do this automatically when we have only GA integration enabled in the segment dashboard.
There have been previous issues related to this — #314 , #351 but the official documentation still doesn't give any hints about loading only necessary integrations.
The text was updated successfully, but these errors were encountered: