I currently have a page http://proctors.org/tv that is driven by several views and attachments with tons of jQuery and hacked-together JavaScript spaghetti, and I would like to clean it up. I understand that newer Javascript "MVC" frameworks make use of templates, and don't strictly store all the data in the DOM as you might do with jQuery.

I believe you would use something like Services and/or Views as the backend, with Backbone on the front.

There is a D.o project for Backbone, and I remember there being a BoF or Session at DrupalCon Denver about it...

I am hoping to discover if it is worth my time to try and rewrite this in a new framework or just clean up what I have here.

  • 4
    What is the question, exactly? If the question is "Is anyone using Javascript frameworks like Backbone or Ember with Drupal?" then it is a poll, and as such is not welcome on Stack Exchange sites. If you have a specific question about using one of those JavaScript frameworks, then ask that question. – kiamlaluno Aug 7 '12 at 13:29
  • 2
    I think he's asking if there exist any MVC javascript frameworks that can work sufficiently well with Drupal's own javascript framework that they would result in less work than simply rolling his own. Seems fair to me - for some things, intigrating with Drupal goes beautifully smoothly, for others, it needs so much hacking you'd be better to just rewrite it from scratch - and it seems fair to ask people who've already tried. – user56reinstatemonica8 Aug 9 '12 at 11:12
  • If you want a quick tutorial to get backbone + drupal up an running you can check out my blog post pixelite.co.nz/article/… – masterchief Jul 22 '13 at 23:28
  • This guy has a good starting point for backbone and Drupal pixelite.co.nz/article/… – Dan Walmsley Jul 22 '13 at 23:28
  • Ha that guy is @masterchief from one of the answers above – Ryan Price Jul 24 '13 at 11:55

I have used both Ember and Backbone along with Drupal - but not in the way you would think.

Ember and Backbone are both fine tools to create a web application - but Drupal is not really a good tool to be used along with them. What you desire when you built a web app is something light and fast. You want it to be fast to be able to give your users the feeling if immediate response times. You want it to be light to make it scale better. Drupal is not fast - the full Drupal bootstrap takes a long time (compared to a lot of other options) if all you want to do is provide a REST API for your web app. Drupal is PHP, which also makes it quite RAM hungry limiting the number of concurrent users.

So if Drupal is so bad for this why use it?

You should really use Drupal for what Drupal excels at - a CMS. What I've done in the past with projects that needed a web app is to use Drupal to create the CMS around the web app. To build stuff like blogs, content lists and the likes. I also created modules to define some backend stuff - like schema definitions, and other stuff where it made sense to use Drupal - because it made my development much easier.

Instead of using Drupal to create the REST API that the webapp needed - I used Node.js to create the actual REST API and other checks AJAX calls that the webapp needed to make. Node.js excels in doing just this. It's blazing fast (response times as low as 30ms for a list of objects). It's also very lightweight, since JavaScript on the server uses asynchronous actions, a Node.js server can usually handle thousands of concurrent users where PHP can handle maybe 100. In addition to that - since Node.js is JavaScript, you can reuse a lot of the code server and client side. You can literally write the same validation code, instead of having to implement both client side in JavaScript and server side in PHP. If you are going to Drupal con in Münich in a few weeks - you should consider watching the node.js presentation.

So if you are a developer, I would strongly recommend doing a similar setup, and only use Drupal for what it is really good at. If you want to make a simple webapp and you don't expect a lot of user, using Drupal as a backend could be an option if it helps your development time.

Update Drupal 8

So with the release of Drupal 8 some of the above still holds true but not in the same extend as earlier. Drupal 8 is like Drupal 7 not a light weight tool, like Node.js, Rails, Django etc. Since JavaScript apps mainly consume various services, you still should consider if Drupal is the best tool for this.

With Drupal 8 a lot of things have been improved. Services is a lot more native, with Symphony driving the request/response. Drupal 8 has a lot of interesting possibilities with with the advanced caching and all of the great features. But even with all of the greatness of Drupal 8, it still is a lot heavier than light weight applications. It's hard to tell how successful Drupal 8 can be used as a fast webservice provider.

So still, with all being said and done, my general recommendation stays the same. Being a Drupal developer, it's easy to use Drupal for everything, since we're familiar with it. It feels safe and Drupal can be used for just about anything. Remember while it's possible to use Drupal for anything, it doesn't mean that it's the best tool for everything. Doing a sound analysis and understanding the strengths and weaknesses of the tools you want to use on an IT project, will always be a great help and can help you avoid ending in a deadlocked position with a result that doesn't live up to your expectations.

  • Interesting approach. Are you using drupal.org/project/nodejs or are you rolling your own interface to the Drupal DB? – mpdonadio Aug 9 '12 at 14:22
  • @googletorp, I worked with phusion passenger and even she cannot perform better without caching and server optimization and all server side scripting languages (except js) have fair amount of blocking issue. Infact I myself switched from ruby to php because of some dedicated performance support in open source community and extreme ease of use. Nodejs will always remain faster compared to other languages. – Minty Aug 9 '12 at 16:11
  • Anyways the point is, since Drupal provides awesome services module framework, I thought you could share some knowledge on handling data at client side, especially handing session and stuff. – Minty Aug 9 '12 at 16:13
  • @Minty There is a helper package for integration to Drupal in Nodejs : github.com/mikl/node-drupal The actual session handling depends a lot on how/what you do. CORS etc, but I usually send the Drupal session_id either a cookie or in the request header. – googletorp Aug 10 '12 at 11:12
  • I just read through this awesome Backbone documentation github.com/kjbekkelund/writings/blob/master/published/… and thought, man backbone is a great way to organize your JavaScript and use it with AJAX callbacks via the routing system. Why not combine it with Drupal since Drupal relies on the same routing characteristics? – AlxVallejo Aug 24 '14 at 15:24

I have recently begun developing my first backbone + drupal application and am really enjoying it. Using the Backbone module along with Services, Services Views, and the required libraries. The project is quite simple: To create a content manageable carousel of 6 pages that display various data, along with an additional News slider that displays different content. This page sits on various screens without user interaction so required the ability to update the front end content without refreshing the browser. I thought this fit perfectly into a Drupal + Backbone app with Drupal managing the content and backbone controlling and syncing with the db. I integrated in jquery.cycle 2 which has an awesome API and fits well into the MVC style of coding.

I can see why people might stick their nose up at using Drupal as the backend framework but for a small application like this Drupal is light and fast. I achieved this by starting with a minimal install and carefully picking contrib and core modules. I'm now at around 50 modules with just under 150 lines of custom JS code for the backbone stuff and I'm pretty much done.

Eventually I will try to commit this back as an example to the backbone module as there is currently no example which shows how to use Views as collections etc.

In conclusion:

It is worth your time to look into this if your project matches well. In my opinion, performance issues derived from the heaviness of Drupal can be easily combated by using caching mechanisms like Varnish, or even boost or core page caching. The flexibility and speed of development from using Drupal completely outweighs the negatives for me.


The basic answer is yes, some people are using it. I have not used it myself (haven't found a good project match yet), but there is currently a Drupal group for it, and it would also fit in with the Web Services and Context Core Initiative which is one of the Drupal 8 Initiatives. There is also a session at DrupalCon Munich 2012, Backbone.js in the Frontend.

I don't know if it is ready for prime time yet, but in my opinion it is worth creating a proof of concept for if you have something that could benefit from it, and can design the JS side to an interface and not an implementation. That would help isolate any backend changes should you decide to bail on Drupal, for whatever reason.

  • 1
    Essentially: Stackexchange is the wrong place to ask about this, since it's such a special case at this point. Wander on over to the group discussion on g.d.o. – paul-m Aug 8 '12 at 19:33
  • MPD thanks for the link to the group. I will probably follow up there. I had done some asking around at user groups, which really depends on who is there. Still trying to figure out when I should start a question on Stack Exchange. I figured this would have more than one right answer, so it seemed like a fit. – Ryan Price Aug 10 '12 at 14:09

You might find this useful : it shows an example of converting a JQuery based script into a backbone script. Obviously you will need to pull in backbone.js, either as a library using drupal_add_js or using the module.


  • Hi Craig, thanks for the link, do you have any resource where this is used with Drupal in specific? Thanks – Minty Aug 10 '12 at 9:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.