Selecting Scripts

When creating web pages you may want to add some JavaScript to your page to allow it to interact with your visitor but you don't want to go to the trouble of learning JavaScript. To cater for people like this there are many scripts that people have made available for others to use (see my scripts for some I have written). Scripts that are available to use will generally have a comment at the top specifying the conditions under which you can use it, you should never just take a script from someone else's page without their permission. The problem is that scripts that are made available for others to use will have been written at different times and what was considered good JavaScript at one time may not even work in modern browsers. There are even JavaScript classes around today that teach how to write JavaScript for use with early Netscape browsers so just because someone has taken a JavaScript class doesn't mean they know how to write JavaScript suitable for use with current browsers. Also many people with just enough knowledge of JavaScript to throw something together that sort of works in their browser (but possibly not in other browsers) can make scripts available. So how does someone who is looking for a script without knowing any JavaScript know whether the script they are looking at is a well written script or one that is basically junk?

While you cannot tell for certain just what the quality of the script is, there are a number of things you can quickly search for in the script that will eliminate a lot of the junk and older scripts written for early browsers. There are also a few simple things to search for that will help you to choose between two scripts.

Let's look first at a few things to look for where you can safely say that you are looking at something either written for early browsers that is unlikely to work in current browsers or where the person who wrote it knows perhaps as much as five minutes more JavaScript than you do. Discard any script that uses any of the following and keep looking for a more modern script.

So having eliminated at least a good portion of the junk, you may still have a selection of alternative scripts to choose between that all appear to do what you want. Ideally you want to choose the version that is the least obtrusive (involves the minimum changes to your page to attach it and doesn't interfere with other scripts you attach to the same page). The following are some of the things to help you compare scripts so as to choose the one that is more likely to be the better written one.

By doing these few simple searches you will be far more likely to select scripts to use with your web pages that will work properly with current and future browsers and which are less likely to interfere with one another if you attach two to the same page. You may still end up with a script that isn't the best one available that does what you want it to do (you may not have even found that one) but at least you will have discarded some of the junk scripts and chosen one that is amongst the better ones that you found.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow