One Plugin to end all jQuery Plugins

So far so good


Perhaps. What is this good for? Ok, for starters what we have here is an “meta thing”. “Meta concept”, overarching abstraction of a familly of abstractions. An “zigot” of meta-programming. In this case “plugin-of-plugins”. I shall call this “Meta Plugin”. Ok, but why is this a “good thing”?

For example , jQuery plugins are (badly?) missing name-spaces. There is no inbuilt classification of plugins, nor is there a valid way to do so. Which in the presence of hundreds of plugins is a problem. In the presence of thousands of plugins it will be (is already?) a nightmare. And to change jQuery plugin mechanism itself, is already a nightmare because of legacy plugins.

But, consider if everybody will be using “Meta Plugin” as an template? Simple but ubiquitous measure, which will give an single level hierarchy of namespacing for templates. Simply use this pattern, but in implementing it give it “your name”.

All the “Meta Plugin” implementations above are identical, but all are named differently. This guarantees (to some degree) re-usability of callbacks between different name-spaces. Like the callback c1() in the code above. This approach can be easily standardized by jQuery.

Name-spacing without name-spacing. Again if ubiquitously used this simple mechanism will do a lot of good for jQuery. It is indeed “yet another level of indirection” which makes code slower, but it seems it will be well worth it.

Now. There was/is a lot of discussion on how to develop re-usable architecture for jQuery patterns, how to “sneak in” namespaces, etc. All of this has proven that jQuery plugin namespaces can not be done properly without changing jQuery itself. And jQuery rightly team has not shown inclination to do so.

This “plugin meta architecture” is very unobtrusive and is not stopping anyone indulging in the above kind of plugin mental activity. The only requirement is to move all of that activity and solutions onto the callback object used here. So, one can fire away and do her favourite “ninja” scripting, but all in and around a callback object.