Live data from Hacker News

Lists of JavaScript methods which you can use natively

github.com

21–30 of 162 posts

Re: Lists of JavaScript methods which you can use natively

#21
You might also not need to write any code at all, just set up a form for customers to send in their requests and hire a bunch of people to manually process them. Bam! 0K, no dependencies, almost instantly working web service.

But that's not your priority when building website, it doesn't matter if your JS is 60Kb or 20. No one cares how much dependencies you build system pulls. You need tested, reliable and working libs to do their job, and not write your own routines for 3 months.

Re: Lists of JavaScript methods which you can use natively

#22

"However, when you are targeting modern browsers" - possibly one of the worst mistakes companies do. Then they decide to support older browsers after customers complaints. Then shit goes down!

I've yet to see a company going under and citing lack of old browser support as principal culprit.

Re: Lists of JavaScript methods which you can use natively

#23
post #11

There's a huge gotcha: _.map, _.forech, ... can iterate over objects (often used as associative arrays) - Native map can't. At some point you'll need lodash and co again - at least for convinience.

Object.keys() is rather well supported these days though.

Yes, but means that you need to implement map, foreach, filter yourself. So you might be better off with lodash.

Re: Lists of JavaScript methods which you can use natively

#24
Getting rid of unnecessary dependencies can have a huge impact on site download performance, especially on mobile. Even in the case of having the site cached, every resource you link will have to perform an HTTP request to at least receive NOT-MODIFIED. It can add up, especially if you're on a semi-spotty connection and trigger TCP congestion avoidance.

Re: Lists of JavaScript methods which you can use natively

#25
post #18

Instead of searching for the compatibility of each individual function I would much rather just use a custom build of Lodash with the collection of functions I need (which can even be handled by your build process now and some tree shaking). And I get a lot of utility functions with it too that I use a lot like Throttle and Debounce.

If you just use lodash from a CDN, many, many users will already have it. If you make a custom build, then everyone has to download.

Didn't someone do a study and found that cache hit rates for CDNs were in the 10-20% range?

You might be better off bundling lodash and tree shaking everything you don't actually use away.

Re: Lists of JavaScript methods which you can use natively

#26
post #18

Instead of searching for the compatibility of each individual function I would much rather just use a custom build of Lodash with the collection of functions I need (which can even be handled by your build process now and some tree shaking). And I get a lot of utility functions with it too that I use a lot like Throttle and Debounce.

If you just use lodash from a CDN, many, many users will already have it. If you make a custom build, then everyone has to download.

If he is building his code then he is probably bundling and minifying his entire client source together and being selective just keeps the build code smaller. Having one request for all of the client is more preferable to some. Anyways, I'm just saying I don't think he is just building a minified fork of lodash.

Re: Lists of JavaScript methods which you can use natively

#27
post #18

Instead of searching for the compatibility of each individual function I would much rather just use a custom build of Lodash with the collection of functions I need (which can even be handled by your build process now and some tree shaking). And I get a lot of utility functions with it too that I use a lot like Throttle and Debounce.

If you just use lodash from a CDN, many, many users will already have it. If you make a custom build, then everyone has to download.

If you only need a couple of functions though, and makes your JS bundle just a few bytes bigger, getting the whole thing from the CDN is kind of silly.

Especially for those with empty cache (need to make 1 extra DNS request, download 1 extra file, which is mostly unneeded, etc).

Re: Lists of JavaScript methods which you can use natively

#28
post #18

Earlier quoted context omitted.

If you just use lodash from a CDN, many, many users will already have it. If you make a custom build, then everyone has to download.

If he is building his code then he is probably bundling and minifying his entire client source together and being selective just keeps the build code smaller. Having one request for all of the client is more preferable to some. Anyways, I'm just saying I don't think he is just building a minified fork of lodash.

I shouldn't have said fork since it is just building but oh well.
Post reply on HN