jQuery Plugin Development Tips

30 Mar

Rise Safe Your Plugin Naming is Peculiar – Total naming conventions in your plugin, including it’s call, rank and id’s should exist to the degree that unexampled during the time that in posse to elude conflicts by other CSS and JavaScript collection of laws and further weighty other jQuery functions.

Restrain Your Digest Separated – Help like a great quantity of the same kind with likely mixing your CSS and JavaScript collection of laws. You at no time comprehend the sort of a developer may straits to lower, in the way that it’s most good to keep these things in their respective files.

Please NO Hard Coding – This is the most frustrating thing to come across in any plugin you use. A hard coded file path in the JavaScript code that assumes you will be using the root path or something. Image paths can all be set in the CSS using background images, and paths in the code should all be written relative to begin with.

Your jQuery Plugin Should Work Out of the Box – Anytime a developer uses your plugins there should always be at least a default mode that just Postgresql update user works out of the box. When they call your plugin something should happen, if you don’t at least have this, chances are people will pass on your plugin and keep looking for others. This makes it really easy for the developers and now allows them to tweak options as necessary.

Provide Plugin Options – This follows from the point above, once your plugin is working any modifications to it should be provided through some options. Don’t ask developers to have to create some kind of structure with div’s. Although this rule case can be broken as in the case of a jQuery slideshow plugin where a user may want to specify multiple images, for the most part, keep this in code and set it as an option to toggle on or off.

Thoroughly Test Your Code in All Browsers – This step is easy to do and only takes a little extra time and effort. This is also probably the most important step which will make or break your plugin. In many cases a developer may not find a bug in your code but a user most definitely will sooner or later. If users are reporting bugs and it turns out to continuously be your jQuery plugin, there is a good chance it will get dropped and replaced. Make sure you run a quick test in all browsers and sort out any last minor issues before release.

Document Your Plugin Code – Before releasing your plugin make sure you document it. Your code makes sense to you because you just wrote it, but it may not make sense to others or even to yourself three months ahead of time.

See the tips in action here with my jQuery Tooltip.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: