Topic on Talk:Requests for comment/Isolate custom jQuery libraries

Matma Rex (talkcontribs)

This might be a little out of scope for the RFC, so I'm commenting here instead of inline. You mention Underscore.js in a few places – has anybody considered including it in core, preferably as a default library like jQuery? Because I'm getting really tired of not having a sane consistent set of functions for "advanced" features like whitespace trimming, regex escaping or a sane map() function :)

Dantman (talkcontribs)

I'm in favour of including either Underscore.js or Lo-Dash. I've tried using them a few times recently and they've worked out quite well. I started out with Underscore. Lo-Dash is also popular on node, Grunt actually uses it.

I wouldn't say "default library" myself. Though that stems from my current opinion of not entirely liking the way we don't declare 'jquery' on things that use it. Also given the possibility of an Underscore vs. Lo-Dash debate it's probably a good idea to explicitly declare the name of the library and use an IIFE that maps either underscore -> _ or lodash -> _ (running either one or both in noConflict mode may be reasonable). That way if anything happens it's not too hard to slowly migrate everyone to the other library.

((Side topic we may also want to look at Lazy.js. Not as default in any way. But occasionally we may run into cases we are doing things that do a number of sequence operations on a large list of items. In which case it would be useful to include Lazy.js and it's different API for that specific use.))

Just to cut you off though. Underscore.js/Lo-Dash provide those map, each, filter, etc... array methods (as well as a bunch of bonus stuff for objects and functions) however they don't include any string functions.

String functions are provided by the Underscore.string.js library – which does work with both Underscore.js and Lo-Dash – which is 3rd party and not made by the authors of either Underscore.js or Lo-Dash. So it may not be as popular as the other two (though I think Grunt still uses it with Lo-Dash). There is a bug or maybe two we may want to push to have fixed before we start using Underscore.string.

Reply to "Underscore.js"