Please optimize the size of libs
Problem
Could you optimize the size of libs? We have limit ~ 50 KB per route on 3G mobile networks. :-/ Check out the video Measure Time to Interactive. The Cost Of JavaScript is high. - 27.8 KB / gz 9.3 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-app.min.js - 268 KB / gz 69.4 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-firestore.min.js - 178.3 KB / gz 46.4 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-database.min.js - 33.9 KB / gz 10.5 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-storage.min.js - 27,8 KB / gz 5.7 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-messaging.min.js - 137.5 KB / gz 43.8 KB https://cdn.jsdelivr.net/npm/firebase@4.6.2/firebase-auth.min.js
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Please optimize the size of libs
Hi Guys, I want to provide some updates on what we are thinking about the size optimization. We had a lot of discussion about it recently. While it’s not completely settled, I can share some ideas we have discussed. At the root of the issue, firebase components expose the entire API surface in the component instance. For example, all Firebase Auth APIs hang off the firebase.auth() object. Bundler
Trust Score
8 verifications
- 1
Hi Guys, I want to provide some updates on what we are thinking about the size o
Hi Guys, I want to provide some updates on what we are thinking about the size optimization. We had a lot of discussion about it recently. While it’s not completely settled, I can share some ideas we have discussed.
- 2
At the root of the issue, firebase components expose the entire API surface in t
At the root of the issue, firebase components expose the entire API surface in the component instance. For example, all Firebase Auth APIs hang off the firebase.auth() object. Bundlers can’t tree shake them because they can’t be statically analyzed. To solve the problem, we need to export functions/classes as top level module exports to expose the APIs, so you can explicitly import what you need. For example:
- 3
Just to clarify, this is just an example to illustrate the idea. The functions a
Just to clarify, this is just an example to illustrate the idea. The functions and their names are likely to be different in the final product.
- 4
Besides the API changes, we also have a lot of work to do to refactor the implem
Besides the API changes, we also have a lot of work to do to refactor the implementation in order to decouple components and separate interconnected logics, otherwise you might run into a situation where you import just a few symbols but end up pulling in 80% of the codebase.
Validation
Resolved in firebase/firebase-js-sdk GitHub issue #332. Community reactions: 62 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep