Print Shortlink

Issues with standalone jQuery/jQuery Mobile

Scanning the code of my recently concluded project using jQuery and jQuery Mobile threw light on a number of issues with using these two libraries in a project. Yes, there are lot of positive points of using jQuery/jQM but let’s jot down few negative points.

  • There’s no built-in design pattern/strategy to write jQuery code in our applications. It lands up looking like a C-program finally.
  • The mobile applications use the single HTML file architecture. Maintaining the UI code in a single file as you would do in jQM is certainly very bad and painful in the long run.
  • You have to put in effort to segregate the JS code in different files, based on the functionalities.
  • The previous point makes it difficult to use a library like QUnit for testing.
  • After modularizing the code in different JS files, you have to include these scripts using the script tags in your single HTML file and mind you, in the correct order.
  • If you add all these JS files in HTML, say you have split your jQuery code in 10 files, the browser will send 10 requests to load every file, which is pretty horrible.
  • jQuery Mobile does not provide any facility to develop templated/reusable UI. For instance, if you want to have a footer on every screen, then you need to think of a pattern to not duplicate this piece of code.
  • jQuery leads to an explosion of global variables in the application.
  • jQuery mobile is very simple, but still ill-suited for building enterprise applications. You would anytime prefer using Sencha Touch for that.

In summary, it’s very difficult to maintain the application build using vanilla jQUery and jQueryMobile.

Off late, we have been stressing our clients to use jQuery and jQueryMobile with frameworks like Backbone.js and require.js. Backbone takes care of the segregation of your code into views and models. Require JS takes care of the dependency management, optimizing the loading of JS files and also organizing the code into modules. If you have to create maintainable jQuery code, you’ll have to use these libraries alongwith.

The moral of the story is, never use jQuery/jQM alone in your project. Use it with Backbone/require or even KnockOut.js.

Page 1 of 1

One Response

  1. Vinoth

    Well said prabhu, I liked it.

Leave a Reply


+ 2 = seven