You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, a browserified loopback module has about 1.4MB uncompressed, 650KB compressed. This size is unacceptable, especially for mobile browsers on a slow internet connection. We need to get at least below 100kb.
This GH issue is a time-scoped story. The goal is to analyse the dependencies, fix as many low-hanging fruits as possible and then create follow-up stories for the unsolved items.
My plan is to produce profiling data using file (bundle) size instead of execution time, so that we can identify the files and modules that contribute most to the overall size. There may be an existing browserify module for that, I did not check yet. (Please let me know if you figure out how to do this.)
Once we have that information, it should be easy to pick the biggest dependencies, check if they are used by the browser client, and exclude them using browser field in the relevant package.json field if they are not needed.
"This issue really renders offline / isomorphic usecases for loopback unworkable in production"
We decided not to use loopback / strongloop just because this issue.
People are complaining that jQuery has 35kb and this is too much for mobile.
A rest library with 2-5 models should not consume more than 50kb gziped.
Maybe you should provide another entry point with has just the client network stack and model definitions instead of browserifying tons and tons of server code.
Maybe you should provide another entry point with has just the client network stack and model definitions instead of browserifying tons and tons of server code.
+1 for this
Its really not as out of reach as it might sound. I think @bajtos has mentioned some of the steps to do this.
This is what I'd like to see:
a build script (eg. a gulp file) included with the boilerplate of loopback (output of slc loopback)
outputs a browser version of your client directory
the build will exclude and shim modules to make the bundle a reasonable size
only includes modules required by your configuration (also in the build script).
eg.hasPassword() will not be supported and its deps will be shimmed with empty modules
allowing you to opt into features that require significantly larger modules
One of the biggest issues though, it seems, is compacting the size of the datasource juggler. This and loopback seemed to be the largest modules in the bundle.
I'm with @jantimon. I've used pouchdb before and it's great and achieves a lot for a small library. We could probably come up with a thin client ODM that works like loopback datasource juggler without necessitating all the cruft of loopback itself. Like he was suggesting, on client boot it would request a payload of model definitions, learn about additional REST endpoints, etc. Then there could be simplified loopback-connectors for localstorage, pouchdb, linvodb3, etc for client-focused implementations.
Generally, the real need becomes a much greater modularization of looback and the datasource juggler if you plan on continuing to bundle any of this together for the browser, especially with optional modules. Currently it appears to be all or nothing.
Another idea is this - what if we were to build a library that could be used to inflect the logic of the loopback ODM into customized generators, as defined by your application? So you could create generators for angular $resource, ember data, for superagent and/or for flux implementations, all from the same logic.
Activity
BerkeleyTrue commentedon Mar 6, 2015
@bajtos any advice or strategies on this?
bajtos commentedon Mar 9, 2015
My plan is to produce profiling data using file (bundle) size instead of execution time, so that we can identify the files and modules that contribute most to the overall size. There may be an existing browserify module for that, I did not check yet. (Please let me know if you figure out how to do this.)
Once we have that information, it should be easy to pick the biggest dependencies, check if they are used by the browser client, and exclude them using
browserfield in the relevant package.json field if they are not needed.BerkeleyTrue commentedon Mar 10, 2015
So the first step is to get the size of each file/script in the bunde?
bajtos commentedon Mar 10, 2015
For each file/script, you need two values: the size of the file itself, and the cumulated size of all dependencies including the file itself.
For example, a single-line file
var loopback = require('loopback')is small itself (about 20 bytes), but huge when dependencies are included (1.4MB).8 remaining items
mattaylor commentedon Jul 30, 2015
Any movement here? This issue really renders offline / isomorphic usecases for loopback unworkable in production
LucaColonnello commentedon Aug 18, 2015
+1
jantimon commentedon Aug 28, 2015
"This issue really renders offline / isomorphic usecases for loopback unworkable in production"
We decided not to use loopback / strongloop just because this issue.
People are complaining that jQuery has 35kb and this is too much for mobile.
A rest library with 2-5 models should not consume more than 50kb gziped.
Maybe you should provide another entry point with has just the client network stack and model definitions instead of browserifying tons and tons of server code.
pouchdb is doing the same job and requires only 45kb: http://pouchdb.com/
ritch commentedon Aug 28, 2015
+1 for this
Its really not as out of reach as it might sound. I think @bajtos has mentioned some of the steps to do this.
This is what I'd like to see:
slc loopback)hasPassword()will not be supported and its deps will be shimmed with empty modulesacao commentedon Aug 28, 2015
This is great!
One of the biggest issues though, it seems, is compacting the size of the datasource juggler. This and loopback seemed to be the largest modules in the bundle.
I'm with @jantimon. I've used pouchdb before and it's great and achieves a lot for a small library. We could probably come up with a thin client ODM that works like loopback datasource juggler without necessitating all the cruft of loopback itself. Like he was suggesting, on client boot it would request a payload of model definitions, learn about additional REST endpoints, etc. Then there could be simplified loopback-connectors for localstorage, pouchdb, linvodb3, etc for client-focused implementations.
Generally, the real need becomes a much greater modularization of looback and the datasource juggler if you plan on continuing to bundle any of this together for the browser, especially with optional modules. Currently it appears to be all or nothing.
Another idea is this - what if we were to build a library that could be used to inflect the logic of the loopback ODM into customized generators, as defined by your application? So you could create generators for angular $resource, ember data, for superagent and/or for flux implementations, all from the same logic.
TonyLuo commentedon Sep 9, 2015
+1. I only use some models . Is any way to define which models should be generated and which should not be generated in the AngularJS client file?
bajtos commentedon Sep 9, 2015
This issue (#989) is discussing the size of the client bundle produced by browserify.
Please open a new issue in loopback-sdk-angular to discuss feature requests for the AngularJS client code generator.