Why should you code jQuery plugins?

Like in X-files in jQuery world, we can say the plugin is out there.  They exist thousands or even millions of plugins solving a wide range of problems and with  a wider range of quality.

In this scenario some people says that is better use existing plugins than coding new one. And in most cases this is truth.

But I think that still now is best practise to code some plugins.  

You can code a plugin only for test,  without  intention to publish or use it in production sites.  It is a good way  to practice Javascript,  understand better how jQuery  and   his plugins system works.

But only if you code a plugin  with the objective of be used in real enviroments,   and  better if it is released to the public domain.  When you force yourself  to think  about reusability.  Doing the documentation for other users is a great way  to understand if your plugin rocks or sucks. And with documentation and samples  is more easy that you reuse this plugin in other projects.

If you make a plugin you are focusing in make the code more reusable and more generic.  With options you’re making your code more flexible.  And if you maintain your plugin then you are suffering your own mistakes and this is a great way of learn and inspiration ;).

But when is time to code and when is time to search? In theory its easy to decide if it is better to code a plugin that you need or  search for a plugin that does what you need.  The rule of thumb is which option take less time?  But in practice we know that this is a question without a easy answer.  As developers  we fail making predictions more often that we prefer.

Then we can take more realistic approximations to make a good decision:

1.  You need a very simple or concrete case,  then you can code a plugin focused on this case,  it will be more lightweight  than a general one,  and it will be more fitted for your  requirements.

2.  If the plugin exists but  is  hard to personalize  and it has extra behaviours  that you don’t need  or you don’t want.  I’m thinking about form validation,  jQuery.validate is a great plugin, but if you only need to guarantee that the fields aren’t empty, could be easy to make  a simpler plugin to achieve this objective.

3. You require a very specific functionality and it seems difficult to find something that does what you are looking for.  

Then if you decide to code a plugin where should you start?

The resources are out there,  here is some interesting ones : (jQuery) (Addy Osmani)  (Script Junkie) (Developer Works)

and so on ...

And some resources that can be useful for learning Javascript or for improve yours Javascript skills.

comments powered by Disqus
Comunicatek - - La Bisbal d’Empordà - - About code - Legal