I am building a rather large web application and have built a handful of plugins using the classic plugin pattern. Some of these exceed 50 lines and maintain state. I recently discovered jQuery UI’s widget factory, and it appears if I were to convert my plugins to the this style, the code would be easier to read and maintain. Other than time and effort, I’m trying to determine if there’s a downside an converting them over. I already use jQuery UI for some other plugins.
Share
I’ve decided to convert one of the more complex stateful plugins to use the jQuery widget factory. There was a bit of a learning curve, I believe the benefits justified the work. While I’m not leveraging theme roller support, here are some of the other benefits I found useful:
Obviously, you can achieve all of these with the traditional plugin pattern. But the code appears much cleaner to my eye and will be much easier to maintain in the longer term. Many thanks to Eric Hynds and his MuliSelect Widget for providing source code for me to study and learn how to use the Widget Factory.