Closure compiler externs files for underscore and backbone js

by Luke Rodgers on May 8, 2012

As part of some other things I’m working on I’ve begun building upon some existing closure compiler externs files for the Underscore and Backbone js libraries. Both are still in quite early stages, but if you need something like this, they’re currently better than nothing.

backbone-js-externs on github, for Backbone 0.9.2

underscore-js-externs on github, for Underscore 1.3.3

The Backbone externs file is taken from this gist, which was autogenerated by DotNetWise’s externs extractor. It does a decent but very basic job.

The Underscore externs file is taken from the official Closure Compiler repository. The only changes I’ve made so far are

  • fixing a type annotation for the _.uniq and _.unique functions that had a required parameter after a non-required one (Closure Compiler dislikes this)
  • using same type annotation for _.uniq and _.unique, since the latter is an alias for the former
  • beginning to add type annotations for functional-style usage of underscore, vs. object notation (e.g. _(collection).map(function(){}) vs., function() {}). The existing externs file has only the latter.

I’ll probably also be adding externs for use with the SVG library Raphael at some point.


Thanks for sharing these externs files Luke. I’ve tried to use them but encountered some issues with it. I’ve asked the question on StackOverflow (

by John Keyes on June 20, 2012 at 11:29 am. #

Hey John, just did my best to answer your question at the stackoverflow post. cheers

by Luke Rodgers on June 20, 2012 at 11:41 am. #

Hi Luke, thanks for the answer and apologies for my tardiness in replying.

by John Keyes on June 22, 2012 at 5:23 am. #

Thanks for spreading the word about the uadpte. With the number of people still running older releases, and the major security holes that continue to be closed in each 2.0.x release, it is very important to get everyone off of the older versions. The two biggest reasons to upgrade to 2.0.5, as I see it, are:1. This is, again, major security release. There was a major hole plugged;2. If you started your blog with version 2.0 or newer, youe2€™re missing a DB index on the post table and that will slow down your site.Ie2€™ve provided more detail in a top 5 list , but you can always look at the official list of all 60 tickets addressed. I use to look at it in order of priority.Please continue to convince your friends and everyone on your blog roll to upgrade, it is important. If any of them are worried about upgrading, Ie2€™ve included a 35 second upgrade script on my site. Ite2€™s been reviewed by the members of the WP-Hackers list. So, it is safe. Ie2€™d post the link here, but Ie2€™m releasing an uadpted version of it later today and done2€™t want the old links floating around. Just look at the Code Cave article link I posted above and follow it from there. 35 seconds for multiple blogs beats 20 minutes to do it by hand.

by Camila on December 3, 2015 at 10:52 am. #

Templating in WordPress is actually real nice. But that’s all in the eye of the beeldohr.But about backbone.js and underscore. I like the way it gives us the opportunity to create a clean clientside javascript application. Backbone will handle all the application logic. This will open opportunities to create full 3D HTML5 canvas websites, because all data needs to be in js, in order to get into the canvas.So in the media library it would be possible to upload 3d models, instead of images and other boring media.The core will stay the same and why not. WP gave us the chance to CRUD data in a more fashionable way, instead of querying the databases in endless rewinding loops. Loving it. Can’t wait to see some documentation from WordPress.

by David on December 8, 2015 at 2:26 am. #

Leave your comment


Required. Not published.

If you have one.