Web development by Gabriele Romanato

Post navigation

jQuery: when plugins don't work

So far I've rarely used jQuery's plugins in my projects (except perhaps the jQuery UI effects) because every time I found a plugin I stumbled on some problems. First, documentation: the overwhelming majority of jQuery plugins simply tell you what's the basic usage of the plugin and its options without digging into the details of what I call "unexpected use cases". Such cases are compelling and stimulating. For example, I wanted to create a complex content slider where I had a centered slide and two other slides situated each one on the left and right edge of the container. Further, such slides were partially hidden. I searched the web for hours but the only type of plugins I found was the classic floating-based one (and that was not my case). In short, I had to write the code all by myself. Zero plugins, more fun.

A poorly written documentation will almost inevitably lead you to confusion and frustration. Another sign of this is when you read the list of supported browsers. I generally don't trust much such lists, because I always find out that something is broken or missing in our old chap Internet Explorer (version doesn't matter). For example, several months ago I stumbled on a stunning jQuery plugin that emulates the turning of the pages on a classic paper notebook (such as Moleskine). Fantastic! I downloaded the plugin, whose browser support chart claimed to support IE6+, opened it in IE8 and... gasp, it was horrible! You could go out for a coffee and a cigarette and IE8 was still hanging on the first page, trying desperately to honor the specified jQuery effects. Everything was in slow motion on IE, so you got the idea.

Other times, and that's too bad, I've seen a jQuery plugin crashing IE. You may say: "I don't care much about IE" and I respect your position, though you should admit that making a user's browser crash is surely the worst experience for your visitors (according to my personal browsers stats, IE is still there). The best thing a plugin's author can do is to be honest: if your plugin works bad in IE (because IE is IE, you know...), then he/she should explain how to mitigate these differences and if there are some coding alternatives or workarounds (e.g. using a reduced speed or delay in the execution of the animations).

Another thing that puzzles me is when you have a plethora of options and only few demos where such options are combined together. Honestly, it's true that I'm interested in seeing a demo page for every plugin option but it's also true that I'd like to see what kind of effects I can achieve by combining multiple options together. Yesterday I had to run a debugging session on a Wordpress site which makes use of a lot of image effects (slideshows, overlays, you name it) combined together. This site first used Lightbox, then switched to Colorbox. I had to set the title of each image in the slideshow, so I went to read the documentation and I noticed that the title option defaults to false, so I explicitly set it to true. Result? Nothing, nada, zip. Then it came to my mind that most of the options of this plugin accept a callback function instead of a single value. So I specified such function with the alt attribute of each image contained within the trigger link and it worked.

To sum it up: the perfect plugin to be used in all cases doesn't exist. There are only perfectible jQuery plugins, but that's the secret and the beauty of jQuery development: you never stop learning something new. smile

This entry was posted in jquery by Gabriele Romanato. Bookmark the permalink.