Fireship · @fireship
The Decline of Firebase (bundle sizes) // New JavaScript SDK First Look
Uploaded August 4, 2021 · Length 5:15
Summary
Upgrading to Firebase's new JavaScript SDK to reduce bundle size by over 50% and improve performance.
- firebase
- javascript sdk
- bundle size
- performance optimization
- firebase upgrade
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
firebase is on the decline and by that i
- 0:02
mean it's javascript bundle size one of
- 0:04
the biggest criticisms developers have
- 0:06
about firebase is that it requires a lot
- 0:08
of kilobytes of javascript to get the
- 0:09
job done
- 0:10
a large bundle size can lead to poor
- 0:12
performance and a bad user experience
- 0:14
but i have some good news
- 0:15
firebase is releasing a brand new
- 0:17
javascript sdk that can dramatically
- 0:19
reduce the size of your web application
- 0:21
in today's video you'll learn how to
- 0:23
upgrade your existing firebase app to
- 0:24
reduce the bundle size by more than 50
- 0:27
and i'll also give you my first
- 0:28
impressions about what i like and
- 0:29
dislike about this new sdk
- 0:31
because it's filled with breaking
- 0:32
changes but first if you're serious
- 0:34
about building a firebase app
- 0:36
consider upgrading to pro on fireship io
- 0:38
to get access to my full project-based
- 0:40
courses
- 0:41
as developers we always want to use the
- 0:42
latest and greatest technology
- 0:44
gentlemen we can rebuild him we have the
- 0:47
technology
- 0:48
but at the same time we hate dealing
- 0:50
with breaking changes the new firebase
- 0:52
sdk makes it possible to build apps with
- 0:54
a much smaller javascript footprint but
- 0:56
it comes at the cost of a lot of
- 0:58
breaking changes that you'll have to
- 0:59
refactor in your code the problem is
- 1:01
that firebase has been around for a long
- 1:03
time
- 1:03
and it uses what are known as side
- 1:05
effect imports you import and initialize
- 1:07
your firebase app which creates a global
- 1:09
firebase object then extend it with
- 1:11
additional
- 1:12
functionality by importing other modules
- 1:14
like auth firestore storage and so on
- 1:16
this creates a lot of bloat
- 1:18
because these imports add a bunch of
- 1:19
functionality that you're probably not
- 1:21
going to use in your application for
- 1:22
example
- 1:23
your app might use email password login
- 1:25
but importing the auth module
- 1:27
adds the code for every other sign in
- 1:29
method on the platform which is nothing
- 1:30
but dead code that your end user has to
- 1:33
download from the network
- 1:34
instead of accessing methods on one
- 1:36
giant object with dot notation the new
- 1:38
sdk takes a functional approach
- 1:40
allowing you to import the exact
- 1:41
functionality that you need
- 1:43
and that means everything else can be
- 1:44
excluded from the javascript bundle in
- 1:46
other words it's a tree shakeable
- 1:47
library now another cool thing in the
- 1:49
new sdk
- 1:50
is that there's a firestore light
- 1:52
package firestore is the biggest
- 1:54
module in firebase but if you want to
- 1:55
use the database and don't need things
- 1:57
like real-time listeners or offline mode


