Skip to content

Instantly share code, notes, and snippets.

@samleb
Created March 11, 2010 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samleb/328682 to your computer and use it in GitHub Desktop.
Save samleb/328682 to your computer and use it in GitHub Desktop.

Prototype

An object-oriented JavaScript framework

Prototype is a JavaScript framework that aims to ease development of dynamic web applications. It offers a familiar class-style OO framework, extensive Ajax support, higher-order programming constructs, and easy DOM manipulation.

Targeted platforms

Prototype currently targets the following platforms:

  • Microsoft Internet Explorer for Windows, version 6.0 and higher
  • Mozilla Firefox 1.5 and higher
  • Apple Safari 2.0.4 and higher
  • Opera 9.25 and higher
  • Chrome 1.0 and higher

Using Prototype

To use Prototype in your application, download the latest release from the Prototype web site (http://prototypejs.org/download) and copy dist/prototype.js to a suitable location. Then include it in your HTML like so:

<script type="text/javascript" src="/path/to/prototype.js"></script>

Prototype is also available on the Google AJAX Libraries API and can be included directly from their servers like so:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script> � Check out the documentation for further details on how to use this service.

Prototype provides a number of "convenience" methods. Most are aliases of other Prototype methods, with the exception of the $ method, which wraps DOM nodes with additional functionality.

These utility methods all address scripting needs that are so common that their names were made as concise as can be. Hence the $-based convention.

The most commonly used utility method is without doubt $(), which is, for instance, used pervasively within Prototype's code to let you pass either element IDs or actual DOM element references just about anywhere an element argument is possible. It actually goes way beyond a simple wrapper around document.getElementById; check it out to see just how useful it is.

These methods are one of the cornerstones of efficient Prototype-based JavaScript coding. Take the time to learn them well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment