Today's Question:  What does your personal desk look like?        GIVE A SHOUT

How to choose a jQuery plug-in?

  sonic0002        2012-10-27 03:51:40       3,434        0    

jQuery plug-in provides a good way to save time and simplify the development, programmers don't need to write each component from scratch. However, the plug-in will also be a destabilizing factor in your code library. A plug-in saves countless development time, but a poor quality plug-in will cost more than the actual time to write your own component from scratch.

Luckily, usually you have many pls to choose from, but even if you have only one plug-in, you also need to know whether it's worth using or not, don't ever introduce wrong codes into your code library.

Do you need a plug-in?

First you need know whether you really need a plug-in, if not, then don't use any. This will reduce the code size and also save time for learning the plug-in.

1. Better to write yourself?

If the function you require is very simple, you can write it yourself. jQuery plug-ins will often come with various functions, this may be more than what you really need.

For example, if you need more advanced features, jQuery UI accordion is a good choice. But if you only need to open and close the panel. If you have yet to consider to use jQuery UI on your website, then jQuery slideToggle () or animate () may help.

2. Whether you are using a similar plug-in?

When you find that a plug-in can not provide everything, you need to look for another plug-in to make up, very temptation. But in the same application, including two similar plug-ins is certainly not a good choice.Can you find a plug-in including all your needs? If not, can you extend one of the plug-ins to reach your needs? Similarly, in deciding whether to expand a plug-in, weigh the benefits and development time.

For example, jQuery light box is a good choice to display a pop-up photo gallery, simpleModal is a great way to show the user mode information. But why have these two ways on your website? You can easily extend one of them to cover both needs. Better find a plug-in which covers everything, such as Colorbox.

3. Need JavaScript?

In some cases, JavaScript is not necessary. CSS pseudo-selectors, such as: hover and CSS3 transitions functions, can cover a variety of dynamic effects, much faster than the JavaScript solution. In addition, many plug-ins provide only style; it's much better to just use markup and CSS.

If you need to display dynamic content requiring conditional prompts, jQuery Tooltip is essential. However, if only a few place you need to be prompted , it is best to use pure CSS. You can make further use of CSS3 transitions animation, but do not forget that the animation will only be effective in certain browsers.

When reviewing any plug-ins, a series of warning signs shows that this plug-in has poor quality. Here, we will look at all aspects of plug-ins from JavaScript to CSS to mark up. We even consider how to release the plug-in.

4. Weird options and parameter syntax

When using jQuery, developers are concerned about how functions accept parameters. If a plug-in developer uses a special syntax, there is reason to believe that they do not have much jQuery or JavaScript programming experience.

Some plug-ins accept a jQuery object as a parameter, but not allowing chaining of the object, this may not be a good plug-in choice. For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$('.my-selector').myPlugin({
opt1 : 75,
opt2 : 'asdf'
});
 
$('.my-selector').myPlugin({
opt1 : 75,
opt2 : 'asdf'
});
 
$.myPlugin({
opt1 : 75,
opt2 : 'asdf'
}, $('.my-selector'));
 
$.myPlugin({
opt1 : 75,
opt2 : 'asdf'
}, $('.my-selector'));

5. Few or no documentation

It's very difficult to use a plug-in if there is no documentation, because this is the first place to find answers to your questions. Files in various formats, appropriate documentation is the best. If there is no documentation, or just a simple example is published in the blog, then you may want to consider other options. A good document shows the author of the plug-in cares about users. It also shows that they have studied other plug-ins, know the value of good documentation.

Conclusion

When evaluating the quality of a jQuery plug-in, first to assess the quality of the code. Is JavaScript optimized, is there any error? Is CSS adjusted and effective? Is the naming of the mark-up meaningful and flexible enough? These problems are attributed to the most important question: Is the plug-in very easy to use?

Reference : http://blog.jobbole.com/29407/

JQUERY  PLUG-IN 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.