Here’s some more guidance on coding Javascript. There is one thing that really stands out:
Avoid prototype.js
Prototype is a javascript framework that is used in a variety of projects such as Ruby on Rails and Rico. While the framework is fairly popular, has a number of users, and is quite unique, it also has a number of problems which cause headaches for many javascript developers:
- No documentation is available from the author
- No support system is available from the author
- It modifies Object.prototype, so all objects contain additional properties. This causes problems when iterating through object properties
- It forces a class-based OO approach into javascript, which masks the true language features and adds confusion
- It lacks proper feature detection before using some language features, causing it to break in some browsers
Using prototype.js often breaks other working code, so it doesn’t “play well with others”. If you are writing code which only uses Prototype and nothing else, then it can make your life simpler in often ingenious ways. However, its extension of the Object.prototype is the primary reason to avoid using it along with any other javascript cod
I admit I use it. It is very popular in the Rails community. That’s actually where I heard about it in the first place. It seems there are a number of people who view the modification of the base object for Javascript to be a seriously bad thing. So far it hasn’t proven to be that big of a deal for me.
I do have to agree with him that the documentation for Prototype is pretty weak.
Leave a Reply
Moderation Active: Old stuff here... Therefore your comment on this post will be moderated (i.e. don't submit twice !)