Firebase 3 adds 66kb gzipped

341 views
Skip to first unread message

Daniel Steigerwald

unread,
May 23, 2016, 7:03:34 PM5/23/16
to Firebase Google Group
That's a lot. Now whole library has 115kb gzipped. Do you plan to reduce it?

Thank you.

Jacob Wenger

unread,
May 23, 2016, 10:09:49 PM5/23/16
to fireba...@googlegroups.com
Just an FYI for others that this is referring to the web SDK.

Hey Daniel,

TL;DR: We have internal bugs tracking the code size increases. You can actually reduce the bundle size by including only the products you need.

Yes, this is a known issue and we have several bugs open to reduce the size of each individual component. One thing to note is that the package does include a new product (Firebase Storage), so it will by definition be larger all other things being equal.

In the meantime, you can actually pick and choose just the pieces you want / need, although we are lacking documentation on it (that is coming soon!). The individually installable components are:
  • firebase-app - The core Firebase client (required)
  • firebase-auth - Firebase Authentication (optional)
  • firebase-database - Firebase Realtime Database (optional)
  • firebase-storage - Firebase Storage (optional)
From the CDN, include the individual components you need (making sure to include firebase-app first):

<script src="https://www.gstatic.com/firebasejs/3.0.2/firebase-auth.js></script>
<script src="https://www.gstatic.com/firebasejs/3.0.2/firebase-database.js></script>
<script src="https://www.gstatic.com/firebasejs/3.0.2/firebase-storage.js></script>

<script>
  var app = firebase.initializeApp({ ... });
  // ...
</script>

If you are using a bundler like Browserify or Webpack, you can just require() the components that you use:

var firebase = require('firebase/app');
require('firebase/auth');
require('firebase/database');

var app = firebase.initializeApp({ ... });
// ...

I'd love to hear your feedback on this, especially the bundler stuff since I have a feeling you have some experience here. Do you think the above code makes sense? Do it seem too much of a hassle to manually manage this stuff? Do you have any suggestions for us?

Hope that helps!
Jacob

On Mon, May 23, 2016 at 3:56 PM, Daniel Steigerwald <dan...@steigerwald.cz> wrote:
That's a lot. Now whole library has 115kb gzipped. Do you plan to reduce it?

Thank you.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/53a26df9-ee88-4eb8-94ca-1caae32086df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Steigerwald

unread,
May 24, 2016, 10:22:31 AM5/24/16
to Firebase Google Group
That's how react-router does it.
https://github.com/reactjs/react-router/blob/master/docs/guides/MinimizingBundleSize.md

Suggested webpack code doesn't work.

[nodemon] starting `node src/server`

/Users/este/dev/este/node_modules/firebase/firebase-app.js:26

firebase.SDK_VERSION = "3.0.2";

^


ReferenceError: firebase is not defined

    at Object.<anonymous> (/Users/este/dev/este/node_modules/firebase/firebase-app.js:26:1)

    at Module._compile (module.js:413:34)

    at Module._extensions..js (module.js:422:10)

    at Object.require.extensions.(anonymous function) [as .js] (/Users/este/dev/este/node_modules/babel-register/lib/node.js:166:7)

    at Module.load (module.js:357:32)

    at Function.Module._load (module.js:314:12)

    at Module.require (module.js:367:17)

    at require (internal/module.js:16:19)

    at Object.<anonymous> (/Users/este/dev/este/node_modules/firebase/app.js:8:1)

    at Module._compile (module.js:413:34)

    at Module._extensions..js (module.js:422:10)

    at Object.require.extensions.(anonymous function) [as .js] (/Users/este/dev/este/node_modules/babel-register/lib/node.js:166:7)


Can't help more without open sourcing the code.

Mike Koss

unread,
Jun 6, 2016, 7:30:47 PM6/6/16
to Firebase Google Group
require('firebase/app') only works in the browser - not in node (the stack trace you gave looks like running in node).

Note that require('firebase') works for both node and the browser - there are distinct entrypoints ("main" and "browser") in package.json which give you the complete firebase library for each platform.

I've tested browserify, and webpack for both the full require('firebase') and the partial libraries (require('firebase/app')) and I don't replicate these errors.

I think I'm missing something to replicate this problem.

- Mike
Reply all
Reply to author
Forward
0 new messages