Stepping away from the plug-in architecture
At the start of the year I was excited to use jQuery's widget factory. Now I am wary of exposing components as jQuery plugins to the rest of a JavaScript application.
The change of heart came after I spent a day refactoring the jQuery out of an open source jQuery plugin that I found on Github. This was necessary. I was working on a mobile web application that used Underscore/Zepto and the plugin had a good amount of the functionality I was missing.
Now there is enough similarity between jQuery and Zepto that almost all of the 500 or so lines of core code stayed the same. I expect that from a well written plugin. For someone in my situation, there shouldn't have been more to it than swapping out the DOM manipulation library used to enable the component's functionality.
But I also had to refactor the interface to conform to a standard JavaScript object's pattern of instantiation and scoping. That's what makes me scared to start using the widget factory. I don't know the future. But I know that jQuery and it's plugin ecosystem are not necessarily the future in a mobile web world, and I'm not sure that I want to start presenting an interface in my JavaScript applications based on a jQuery centric world view.
At this point, I'd rather have common scoping and invocation patterns in my components, keeping jQuery as a tool used by the components rather than an API that they expose.
The change of heart came after I spent a day refactoring the jQuery out of an open source jQuery plugin that I found on Github. This was necessary. I was working on a mobile web application that used Underscore/Zepto and the plugin had a good amount of the functionality I was missing.
Now there is enough similarity between jQuery and Zepto that almost all of the 500 or so lines of core code stayed the same. I expect that from a well written plugin. For someone in my situation, there shouldn't have been more to it than swapping out the DOM manipulation library used to enable the component's functionality.
But I also had to refactor the interface to conform to a standard JavaScript object's pattern of instantiation and scoping. That's what makes me scared to start using the widget factory. I don't know the future. But I know that jQuery and it's plugin ecosystem are not necessarily the future in a mobile web world, and I'm not sure that I want to start presenting an interface in my JavaScript applications based on a jQuery centric world view.
At this point, I'd rather have common scoping and invocation patterns in my components, keeping jQuery as a tool used by the components rather than an API that they expose.
