FG
🔌 APIs & SDKsGoogle

Please optimize the size of libs

Freshalmost 5 years ago
Mar 14, 20260 views
Confidence Score77%
77%

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

Canonical Fix
High Confidence Fix
76% confidence90% success rate8 verificationsLast verified Mar 14, 2026

Solution: Please optimize the size of libs

Low Risk

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

76

Trust Score

8 verifications

90% success
  1. 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. 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. 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. 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

Worked: 8
Partial: 1
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

firebasegooglesdkapi:-coreenhancement