3 ms·
Javascript is in somewhat of a weird neverland currently. I really want to use this style of library -- mori, Ramda and others are extremely tempting, and fant
by frio 10y ago
Javascript is in somewhat of a weird neverland currently. I really want to use this style of library -- mori, Ramda and others are extremely tempting, and fantasy-land (/static-land, which is more up my alley) are doing great work.
... but, all these libraries are huge. I feel guilty foisting hundreds of kilobytes of JS on my users, just so I can write code that I feel is slightly more elegant. I'm avidly waiting for tree-shaking/jsnext:main to truly take hold, and make these tools more practical.
Gripes aside, congratulations to the Fantasy Land team :).
- wrong_variable 10y agoYou could add Google Closure Compiler to your pipeline. The trick to not breaking your build is to know which libraries GCC can optimize without breaking. The ones it can - browserify them seperately and then ones it cannot - browserify them later. Its a longer step I agree, but its a small price to pay to be in Fantasy Land :D ( sorry couldn't help it )
- rtpg 10y agoI know some libraries are big but this one seems pretty small? A lot of files but each one's less than 1k. If you set up a concat+minifying step in your process (you should be doing this anyways if you're shipping a real amount of JS) then the total cost of a library like this might just be a couple kilobytes. Angular.JS (which has a huge amount of functionality in its core) is only 50kb gzipped.
- frio 10y agoMy understanding is that this is small because it's a specification :). Most of the things I've seen implement it (eg. Ramda) are larger. Yes, I have a concat/minifying step, but as I mentioned, I'd love to see broader acceptance/implementation of tree-shaking. As it is, tying together fantasy-land, Ramda/mori, React, Redux all adds up very quickly (and that's without writing any business logic!).
- smhenderson 10y agoI don't have a lot of experience with js but isn't the idea that you link to their file urls and if everyone does this than users are only downloading once and caching (typically anyway)? Or are you more worried about page load time, not download time? typically unless you're like me and clear cache when the browser closes...
- hyperpape 10y agoCommon misconception. Even on large web properties like Facebook, a large number of users have empty caches. For your site, with less traffic than Facebook, it'll probably be worse. Linking to shared libraries hosted on a CDN often ends up failing because of distinct versions.
- girvo 10y agoLeverage Rollup's "tree-shaking" optimisation along with ES6 modules ("import { Maybe } from 'ramda-fantasy'") and you'll only be adding what features you actually use. Combine it with a decent transpiler (I recommend Bublé) and Uglify and you're off to the races: tiny builds, that work wonderfully.
- frio 10y agoYep! As I mentioned, I agree that this is the future :). We're just not quite there yet (mainly because lots of libraries still don't ship `jsnext:main` entries, and plenty of downstream libraries end up doing an `import _ from 'lodash'` or similar).
- girvo 10y agoTotally agreed. I'm definitely looking forward to it though, that's for certain! Rollup still has a little ways to go, as does the ecosystem in general, but I'm optimistic for sure!