What's the difference between the firebase.js and the firebase-app.js. CDN has firebase-app.js but it is not working until put firebase.js
1 Answer
There are two ways of including the Firebase SDKs in your project from the CDN.
The first is simplest:
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase.js"></script> This includes the Firebase SDKs for all support projects at once, and is great when you are just getting started on developing a project.
But while it is easy to get started, this means you're including about 10 Firebase SDKs in your project, while you may be using only one or two of Firebase's products. So as you get more comfortable with what Firebase products you need, you may want to switch over to the second way of including the Firebase SDKs:
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-database.js"></script> This second approach may be more code in your HTML, but it downloads much less code from the CDN.
For comparison: for version 7.8.0 these are the (compressed / uncompressed) file sizes:
firebase.js: 244Kb / 880Kb
firebase-app.js: 6Kb / 18Kbfirebase-auth.js: 51Kb / 160Kbfirebase-app.js: 49Kb / 181Kb
So if your app uses only the three libraries in the last list, it'd download 106Kb (359Kb uncompressed) instead of 244Kb (880Kb uncompressed) of including the full firebase.js file.