2

Im amazed that even after all this time (jQuery has been around since 2006) we have to resort to adding a plugin or a custom function in order to implement namespaces in jQuery.

// USAGE:
// var myProject = $.namespace('com.foo.myProject');
namespace : function(){
 var o, d;
 $.each(arguments, function(i,v) {
   d = v.split(".");
   o = window[d[0]] = window[d[0]] || {};
   $.each(d.slice(1), function(i2, v2){
    o = o[v2] = o[v2] || {};
   });
 });
 return o;
},

I mean this is a tiny piece of code for a concept that gets used in most Javascript projects and frameworks (above is based on the ext js implementation):

Why isnt this part of jQuery core build? Is there a reason besides "we just havent got around to it yet"?

Community
  • 1
  • 1
Steven de Salas
  • 20,944
  • 9
  • 74
  • 82

1 Answers1

10

jQuery is a framework devoted to facilitating DOM manipulation. It is not an "application framework", really. Read through the jQuery bug list to get a feel for the core philosophy.

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • Do you think the team will cave in to demand for it? – Steven de Salas Jan 09 '11 at 18:15
  • Well, I think that they've been pretty clear in wanting to keep things separate. The UI stuff, for example, is quite distinct from the core library. I'm not on a jQuery committer however. – Pointy Jan 09 '11 at 18:17
  • +1 and I'm glad jquery doesn't try to be my everything. I like it as my swiss army knife. – goat Jan 09 '11 at 18:37
  • 1
    jQuery thrives as a "convenience library." Don't want to type "document.getElementById" over and over again? Want to be able to grab more than just by id? Want some easy animation? jQuery is there to make doing some common JavaScript tasks easy. – natlee75 Jan 12 '12 at 19:15