Snook.ca

Prototype 1.5.0 Cheat Sheet

I've gone through and detailed the methods and properties of each of the modules within the Prototype JavaScript library.

I decided to revisit the cheat sheet. A couple people had been asking about it and with the final release of 1.5.0 just around the corner, now seemed as a good a time as any. I've done things a little differently this time. The first time around, I really just wanted to see how everything was connected and what did what. This time, though, I wanted something a little more practical for me.

First, I've included possible parameters. I've used a shorthand to try and fit everything in, so I hope it's clear. Pretty much anytime a function is passed in, it's for a callback. Anywhere a parameter needed a little more explanation, i included a word before it to describe it.

Secondly, I've dropped some base classes and internal properties or methods. Some of the stuff only serves a purpose within Prototype and it was just clutter to include it in here.

I've done this up in Illustrator instead of Fireworks to ensure that the PDF version would be clean and clear. I realized a desktop version was somewhat annoying; at least, for me it was.

Hey Jonathan, what would I need to do in order to convert you to become a jQuery follower? What reasons do you have to stay with prototype having the elegance of the little J directly in front of your eyes? ; )

Prototype is a great library, I haven't been using it much anymore because I like how compact Mootools is (plus most of the time I don't make use of all of the extra functionality, I just code my functionality myself).

I need to try jQuery yet; I've been hearing a lot of good things. The only reason I haven't touched it so far is because it starts with a J (ironically the same thing that Felix thinks is elegant ;-). The "J[insert name]" to me makes me think Java, and I hate Java with a passion (me and Java, we had some bad experiences together, mostly Java decided to be a douche and I decided it should burn in hell).

Jonathan: Yeah I think YUI does a better job of providing 'a framework' for client side scripting then jQuery does, so I can see why one would use and like it. However, jQuery's elegance in traversing and manipulating the DOM is something YUI does not even come close to. So even if you want to stick with YUI, take some time to play around with jQuery, you will not regret it. You should even be able to use it together with YUI (jQuery is only ~20kb) without any issues.

Andy: jQuery and Java share nothing more then their first letter. I mean jQuery is the polar opposite of the Java philosophy. The best description for it was posted on the jQuery mailing list a while ago and is now on the jquery.com front page:

"You start with 10 lines of jQuery that would have been 20 lines of tedious DOM JavaScript. By the time you are done it's down to two or three lines and it couldn't get any shorter unless it read your mind." - Dave Methvin

If you think that sounds like hype - it's really not. When switching from Prototype to jQuery I found myself using less and less code while doing more and more cool things with the DOM ; ).

Alright, enough jQuery evengalism for today, give it a try and I'll give you a "money back" guarantee if you don't like it ; ).

Felix:
Yeah I know it doesn't have anything to do with Java, its just a stigma I have towards names beginning with a J. They remind me of the countless debugging nightmares I've had with Java in the past. I'd rather debug ASM than Java.

I'll have to play around with jQuery later though, I'm working on a new web interface for Xbox Media Center that is fairly DOM-intensive that it might be useful for.

In your examples of querySelectorAll(), the element.querySelector($this->normalizeEntities16bit("8221")p:first-child$this->normalizeEntities16bit("8221")) code can be written: element.querySelector($this->normalizeEntities16bit("8221")p$this->normalizeEntities16bit("8221")) because only the first paragraph is returned for each li element.

If I decided not to support IE5 and prevent it trying to process the code, to prevent an error would you advice an excluding conditional comment or a JavaScript sniff to achieve this? I have not been successful with excluding IE5 with conditional comments and also achieving strict markup validation.

I'm not really into Prototype, but I was looking for a good PDF Cheat Sheet layout and stumbled onto yours. I am working on some Excel cheat sheets and I was wondering whether I can borrow your layout?

Sorry, comments are closed for this post. If you have any further questions or
comments, feel free to send them to me directly.

Hi. My name is Jonathan Snook and this is my site. I write about what interests me, which is usually web design, development, and technology.
I wrote SMACSS. I tweet. Want to learn more?