I have been familiar with Picora, the PHP framework written by the LivePipe team, but did not realize they also had written an extension for Prototype.js. It turns out they offer Prototype.Extension, which among other features offers these two gems:

  • Cookie object: get, set, and unset browser cookies.
  • Client object: find the browser, OS, and version of the client.

These are simple functions that we probably all have a generic reference bookmarked for, but it is nice to have them integrated into the library. Stumbling across Prototype.Extensions made me think about additional extensions. There seems to be quite a list of available extensions. Here is a small, slightly outdated list of what’s out there, and be sure to keep an eye on the official Built with Prototype collection.

On a similar but unrelated note, Prototype 1.5.1 is nearly complete. Tobie Langel shows us some of the magic with native JSON and window scrolling with the $$ utility.

HTML Form Builder
Ryan Campbell

Extending Prototype by Ryan Campbell

This entry was posted 4 years ago and was filed under Notebooks.
Comments are currently closed.


  1. Joseph R. B. Tayloe · 4 years ago

    Speaking of PHP frameworks, have you tried Code Igniter yet? It seems really nice to me, I’ve done a couple sites with it. Feels like PHP on Rails to be honest, though the scaffolding feature is a little less built up.

  2. Sam D · 4 years ago

    I’d be more then happy to update my list if anyone has any suggestions. I’ll add these tonight.

    Just add comment to http://blog.samdevore.com/archives/2006/07/24/prototypejs-extensions/

  3. Ryan Campbell · 4 years ago

    Hey Sam, I only mentioned it was outdated because the original post date was about 9 months ago. I didn’t realize this was a list that you were actively maintaining. Sorry about that.

  4. Tobie Langel · 4 years ago

    Hi Ryan,

    Thanks for the link-love!

    Note that there’s a lot more info on Prototype’s native JSON in a tutorial which I posted on the Prototype website.

    Regarding Prototype.Extension, there’s some interesting ideas in there, but the browser sniffing is sketchy at best and the Element.getElementsByAttribute relies on the native getAttribute DOM method, who’s support is absolutely horrible in IE. Prototype now has an inbuilt method (Element.readAttribute) to deal with these discrepancies.

    Also note that, as the $$ utility supports CSS3 selectors, this can already be done in Prototype like so:

    $$('[widget]') // returns an array of all 
    // the elements who have a 'widget' attribute.$$('[widget=slideshow]') // returns an 
    // array of all the elements whose 'widget' 
    // attribute is 'slideshow'$('main').getElementsBySelector('[widget]');
    // returns all the children of element "main"
    // who have a 'widget' attribute.

    And yes, the Built-with-Prototype stuff is coming… sorry for the delay!

  5. Sam D · 4 years ago

    Not having gotten many suggestions, I haven’t updated it in a while either ;)

  6. Ryan Campbell · 4 years ago

    I probably should have mentioned it in the post, but I trimmed down the Prototype.Extension library quite a lot. I got rid of everything that wasn’t part of the Client or Cookie object. Browser sniffing is questionable, but I have found that in one or two occasions there is no other way around a problem.

    Thanks for the other links and code. Wasn’t aware of those.

  7. Tobie Langel · 4 years ago

    Ryan, a cookie object is definitely something that should be added to Prototype, maybe in an extensions lib. There’s also a new “secret” feature in 1.5.1… the Prototype.Browser object, which should provide for all the sniffing you need.

  8. Ryan Johnson · 4 years ago

    Tobie, thanks for the Element.readAttribute note, I’ll update Prototype.Extensions. Also in regards to the Browser object in 1.5.1, once the final version is released I will definitely get rid of the Client object. I rarely use the version and OS attributes myself, I more put them in there for completeness.

    I’m thinking of changing the name to Prototype.Tidbits as that more of how I treat it…