Fireship · @fireship

The Decline of Firebase (bundle sizes) // New JavaScript SDK First Look

Uploaded August 4, 2021 · Length 5:15

The Decline of Firebase (bundle sizes) // New JavaScript SDK First Look

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.

  1. 0:00

    firebase is on the decline and by that i

  2. 0:02

    mean it's javascript bundle size one of

  3. 0:04

    the biggest criticisms developers have

  4. 0:06

    about firebase is that it requires a lot

  5. 0:08

    of kilobytes of javascript to get the

  6. 0:09

    job done

  7. 0:10

    a large bundle size can lead to poor

  8. 0:12

    performance and a bad user experience

  9. 0:14

    but i have some good news

  10. 0:15

    firebase is releasing a brand new

  11. 0:17

    javascript sdk that can dramatically

  12. 0:19

    reduce the size of your web application

  13. 0:21

    in today's video you'll learn how to

  14. 0:23

    upgrade your existing firebase app to

  15. 0:24

    reduce the bundle size by more than 50

  16. 0:27

    and i'll also give you my first

  17. 0:28

    impressions about what i like and

  18. 0:29

    dislike about this new sdk

  19. 0:31

    because it's filled with breaking

  20. 0:32

    changes but first if you're serious

  21. 0:34

    about building a firebase app

  22. 0:36

    consider upgrading to pro on fireship io

  23. 0:38

    to get access to my full project-based

  24. 0:40

    courses

  25. 0:41

    as developers we always want to use the

  26. 0:42

    latest and greatest technology

  27. 0:44

    gentlemen we can rebuild him we have the

  28. 0:47

    technology

  29. 0:48

    but at the same time we hate dealing

  30. 0:50

    with breaking changes the new firebase

  31. 0:52

    sdk makes it possible to build apps with

  32. 0:54

    a much smaller javascript footprint but

  33. 0:56

    it comes at the cost of a lot of

  34. 0:58

    breaking changes that you'll have to

  35. 0:59

    refactor in your code the problem is

  36. 1:01

    that firebase has been around for a long

  37. 1:03

    time

  38. 1:03

    and it uses what are known as side

  39. 1:05

    effect imports you import and initialize

  40. 1:07

    your firebase app which creates a global

  41. 1:09

    firebase object then extend it with

  42. 1:11

    additional

  43. 1:12

    functionality by importing other modules

  44. 1:14

    like auth firestore storage and so on

  45. 1:16

    this creates a lot of bloat

  46. 1:18

    because these imports add a bunch of

  47. 1:19

    functionality that you're probably not

  48. 1:21

    going to use in your application for

  49. 1:22

    example

  50. 1:23

    your app might use email password login

  51. 1:25

    but importing the auth module

  52. 1:27

    adds the code for every other sign in

  53. 1:29

    method on the platform which is nothing

  54. 1:30

    but dead code that your end user has to

  55. 1:33

    download from the network

  56. 1:34

    instead of accessing methods on one

  57. 1:36

    giant object with dot notation the new

  58. 1:38

    sdk takes a functional approach

  59. 1:40

    allowing you to import the exact

  60. 1:41

    functionality that you need

  61. 1:43

    and that means everything else can be

  62. 1:44

    excluded from the javascript bundle in

  63. 1:46

    other words it's a tree shakeable

  64. 1:47

    library now another cool thing in the

  65. 1:49

    new sdk

  66. 1:50

    is that there's a firestore light

  67. 1:52

    package firestore is the biggest

  68. 1:54

    module in firebase but if you want to

  69. 1:55

    use the database and don't need things

  70. 1:57

    like real-time listeners or offline mode