Search code examples
javascriptbackbone.jsunderscore.jslodash

Using lodash instead of underscore in Backbone.js application


I'm writing a Backbone application and as I'm reading the documentation online, what I understand is that Backbone's only hard dependency is Underscore. However, I'd like to use Lodash instead of Underscore. Can someone provide steps as to how I can do this?


Solution

  • If you are using Browserify, check out Browserify Swap or Aliasify

    Personally I use Browserify Swap. Example package.json usage:

      "browserify": {
        "transform": [
          "browserify-swap"
        ]
      },
      "browserify-swap": {
        "@packages": [
          "underscore"
        ],
        "all": {
          "underscore.js$": "lodash"
        }
      }