PrototypeJs

For me (and I don’t mind showing a little bias), PrototypeJS is the mother of JavaScript frameworks. Using this library is guaranteed to cut down your development pride. I think it only fair to explain that the PrototypeJS library was what I was thrown into when learning the JavaScript language.

For me, the power of PrototypeJS is in the “$” function. What does it do? Well in short it is shorthand for document.getElementById(). So if you want access to div#myDiv then all you do is: $(‘myDiv’), and you have total access to that element. Furthermore, your element is now extended with all the neat-o and nifty features of the PrototypeJS library, which means functions like setStyle, show, toggle, next, addClassName, and childElements just to name a few (check out their API documentation for a full look at the plethora of functions).

Another great feature of PrototypeJS is the Event. Normally a web programmer would write:

window.onload = showImages;

Well with Event this is what you do:

Event.observe(window,'load,showImages);

Of course that may not seem like much, but there are other events:

Event.observe(window,'load,function (evt)	{ 	Event.observe('myDiv','click', function (evt){  		// --- great code here 	});  });

So, this is just a little introduction to the fantastic PrototypeJS library. It really makes scripting simple and fun. I’ll probably write more on this subject and if you want to know about anything in particular with this library, just let me know.

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