The first release candidate of Prototype 1.6.0 has arrived! The core team is continuing its tradition of bringing thoughtful incremental upgrades to the core APIs in addition to performance improvements and bug fixes. Keep reading for some of the highlights of this major release, or download it now for instant gratification.

Event API Enhancements

We dubbed 1.6.0 the “event overhaul” release internally, and it shows—one of our worst APIs has become one of our best, overnight. Here’s what’s changed:

Event handlers registered with Event.observe or Element#observe are now automatically bound to the event’s target element in all browsers. This means that by default, this in an event handler refers to the element that fired the event. You can override this behavior by passing a bound function to observe. Event objects are now extended with a collection of instance methods. This means you can now write event.stop() instead of Event.stop(event). Furthermore, the event object is normalized with W3C-standard property names in all browsers, so you can now write event.target instead of Event.element(event). The event name and handler arguments to Event.stopObserving and Element#stopObserving are now optional, so for a given element, you can now quickly unregister all its handlers, or unregister all handlers for a single event. References to observed elements are no longer stored in an internal cache, to prevent leaks. Prototype now has support for custom events. Fire them on DOM elements by calling Element#fire with an event name and optional memo object. Internally, Prototype piggybacks your custom events on real DOM events, so they bubble up the document just like click events. This means custom event observers can respond to events fired from child elements. You can observe and fire on the document object for global events.
<div id="container">
  <h1><span id="title">Release notes</span></h1>
  ...
</div>
$("container").observe("titleChanged", function(event) {
  this.highlight({ duration: 0.5 });
});

$("title").fire("titleChanged");
We’ve built in cross-browser support for the DOMContentLoaded event using our custom event system, so you can now be notified as soon as the document is fully loaded:
document.observe("contentloaded", function() { ... })

Function API Enhancements

We’ve added several methods on Function.prototype to better support functional and aspect-oriented programming techniques.

Function#wrap distills the essence of aspect-oriented programming into a single method, letting you easily build on existing functions by specifying before and after behavior, transforming the return value, or even preventing the original function from being called. Here’s an example of using wrap to add behavior to an existing Prototype String method:
String.prototype.capitalize = String.prototype.capitalize.wrap( 
  function(proceed, eachWord) { 
    if (eachWord && this.include(" ")) {
      // capitalize each word in the string
      return this.split(" ").invoke("capitalize").join(" ");
    } else {
      // proceed using the original function
      return proceed(); 
    }
  }); 

"hello world".capitalize()     // "Hello world" 
"hello world".capitalize(true) // "Hello World"

For a less-contrived example, see how you can add jQuery-style element collection methods ($$(“div.widget”).show().highlight()) in under 40 lines of code by wrapping $$ and Element.addMethods.
Function#curry allows for partial function application, like Function#bind, but leaves the function’s scope unmodified.
function sum(a, b) {
  return a + b;
}

sum(10, 5) // 15
var addTen = sum.curry(10);
addTen(5)  // 15

Function#methodize encapsulates the pattern of converting a function’s first argument into its this value.
function addBorder(element, color) {
  return $(element).setStyle({ 
    border: "3px solid " + (color || "red")
  });
}

addBorder("sidebar", "#ddd");
$("sidebar").addBorder = addBorder.methodize();
$("sidebar").addBorder("#888");

Prototype makes heavy use of methodize internally; for example, many Math methods are added to Number instances:
$w("abs round ceil floor").each(function(method) { 
  Number.prototype[method] = Math[method].methodize();
}); 
Function#argumentNames returns an array of strings representing the function’s named arguments, as extracted from the function’s toString() value. Function#delay provides a convenient wrapper around window.setTimeout, and Function#defer is delay with a 10ms timeout.
// add class "busy" after one second
(function() { $("form").addClassName("busy") }).delay(1);
// fire the "requestSent" event asynchronously
(function() { $("form").fire("requestSent") }).defer();

Class API Enhancements

This release marks the first change to Prototype’s class API since version 1.0, and adds true support for inheritance and superclass methods. It’s backwards-compatible with the existing API.

Class.create now supports three alternate forms of invocation: you can now pass a class to inherit from, an anonymous object to mix into the new class’s prototype, or both. The new Class.extend method works like Object.extend, but mixes the source object into the destination class’s prototype. If you’re overriding a method from a parent class, you can now access the superclass method by naming the overriding function’s first argument $super. It works just like Function#wrap (in fact, it uses Function#wrap internally).
var Animal = Class.create({
  initialize: function(name) {
    this.name = name;
  },
  eat: function() {
    return this.say("Yum!");
  },
  say: function(message) {
    return this.name + ": " + message;
  }
});

// subclass that augments a method
var Cat = Class.create(Animal, {
  eat: function($super, food) {
    if (food instanceof Mouse) return $super();
    else return this.say("Yuk! I only eat mice.");
  }
});

Classes now have constructor, superclass, and subclasses properties for powerful introspection of the inheritance hierarchy.

Ajax API Enhancements

Ajax.Request JSON support has been considerably improved in Prototype 1.6.0:

You can now access JSON response bodies as JavaScript objects using the transport object’s responseJSON property. (JSON responses must have a Content-type header of application/json.)
new Ajax.Request("/people/5.json", {        // >> GET /people/5.json HTTP/1.1
  onSuccess: function(transport) {          // << Content-type: application/json
    var person = transport.responseJSON;    // << { id: 5, name: "Tobie Langel", 
    person.city  // "Geneva"                // <<   city: "Geneva", ... }
    ...
  }, method: "get" 
});

The transport object itself is now wrapped by Prototype in an Ajax.Response instance so it can be extended with properties like responseJSON in all browsers. Ajax.Response also features two new, error-proof methods to access headers, getHeader and getAllHeaders; easy access to the transport and request object themselves, with the request and transport properties; and direct access to all the other properties and methods of the transport object for full compatibility.
The following new options are available to Ajax.Request:
sanitizeJSON (true by default) checks the string for possible malicious fragments and prevents evaluation if any are detected. evalJSON (true by default) auto-evaluates JSON data if the response’s Content-type is application/json and makes it available as the responseJSON property of the response object. evalJS (true by default) auto-evaluates JavaScript if the response’s Content-type is text/javascript or equivalent.

DOM API Enhancements

Prototype now boasts a new cross-browser DOM Builder :
new Element("input", { name: "user", disabled: true });
//-> <input name="user" disabled="disabled" />

Internally the DOM builder uses Element#writeAttribute, another new addition to the DOM API which facilitates setting element attribute values in a cross-browser fashion.

We’ve deprecated the Insertion object and Position namespace in this release, and replaced them with methods on Element instead. Element#insert accepts multiple forms of content (DOM elements, HTML, simple text, or any object):

$("items").insert({ after: new Element("p") });
$("items").insert({ top: "<li>an item</li>" });
$("items").insert("<li>another item</li>"); // defaults to bottom

If an object passed to insert contains a toHTML or a toElement method, that method will be used to produce an HTML string or DOM element for insertion.


var Calendar = Class.create({
  // ...,
  toElement: function() {
    var container = new Element("div");
    // ...
    return container;
  }
});

$("sidebar").insert(new Calendar());
// same as $("sidebar").insert({ bottom: new Calendar() }) or
//         $("sidebar").insert({ bottom: new Calendar().toElement() })

Element#update and Element#replace also both now accept DOM elements or objects with a toHTML or atoElement defined. We’ve also smoothed over issues with <table>- and <select>-related elements in IE and Opera 9.
Element#setStyle now accepts either a string of CSS rules (new in this version) or a hash of style/value pairs.

$("header").setStyle("font-size: 12px; float: left; opacity: 0.5");

Note that for performance reasons, we’ve deprecated the use of uncamelized style property names when setting styles using a hash. So If you have code that looks like this:


$("header").setStyle({ "font-size": "12px" });

You need to replace it with either of the following:


$("header").setStyle({ fontSize: "12px" });
$("header").setStyle("font-size: 12px");

Element#identify is a new method which returns the element’s ID if one exists, or sets and returns a unique, auto-generated ID (of the form “anonymous_element_” + auto-incremented digit) otherwise:

<div id="my_div">
  <p>some content</p>
</div>


$("my_div").identify();
// -> "my_div" 
$("my_div").down().identify();
// -> "anonymous_element_1" 


<div id="my_div">
  <p id="anonymous_element_1">some content</p>
</div>

Element#wrap is a convenient and flexible way to wrap DOM elements:

<img id="my_img" />
<span id="my_span">a picture</span>


$("my_img").wrap();
$("my_span").wrap('p', { className: "caption" });


<div><img id="my_img" /></div>
<p class="caption"><span id="my_span">a picture</span></p>

The new document.viewport object lets you calculate the dimensions and position of the browser’s viewport:


document.viewport.getDimensions()     // { width: 1149, height: 923 }
document.viewport.getWidth()          // 1149
document.viewport.getHeight()         // 923
document.viewport.getScrollOffsets()  // { left: 0, top: 1592 }

Template API Enhancements

You can now perform one-off template replacements with String#interpolate, instead of having to first create a Template object and then call evaluate.
"#{last}, #{first}".interpolate({ first: "Andrew", last: "Dupont" })
// "Dupont, Andrew"

If you pass String#interpolate or Template#evaluate an object with a toTemplateReplacements method, the return value of that method will be used as the replacement object. You can now substitute properties of template replacement values in template strings, using dot or bracket notation (or both).
"#{name.last}, #{name.first[0]}. (#{location})".interpolate({
  name: { first: "Christophe", last: "Porteneuve" }, location: "Paris" 
}) // "Porteneuve, C. (Paris)"

Extended grep semantics

Prototype 1.6.0 introduces a new convention for the first argument to Enumerable#grep: the argument must be an object with a method named match, which method grep will call for each element in the Enumerable; if the method returns true, the element will be present in the array returned by grep. What this means is that you can now filter arrays with grep by passing it any object that has a match method. For example, you can now easily pare down an array of DOM elements to only those elements matching a particular CSS selector:

elements.grep(new Selector("div.widget:first-child"))

Prototype aliases RegExp#test to RegExp#match, so existing code that e.g. greps string arrays using a regular expression will still work as expected. The match method convention is inspired by Ruby’s triple-equal (===) operator.

Improved support for JavaScript 1.6 and WHATWG 1.0 standards

We’ve emphasized our commitment to web standards in this release with improved support for JavaScript 1.6 and the WHATWG Web Applications 1.0 specification.

Array#indexOf no longer overrides the native method if present. Enumerable now uses the native Array#forEach instead of Array#_each when possible. Enumerable now has aliases for the JavaScript 1.6 Array methods filter, entries, every, and some, which map to findAll, toArray, all, and any, respectively. All Enumerable methods now have an additional parameter, context, which, if present, specifies the object to which the iterators’ this is bound, for compatibility with JavaScript 1.6 Array methods. Element#getElementsByClassName now supports multiple class names given as a whitespace-separated string, as specified by WHATWG and implemented by Firefox 3. The native version of getElementsByClassName is used in browsers that support it.

...And a whole lot more

These are just the highlights; see the CHANGELOG for the full story. We think the numerous small improvements to Prototype in this release have resulted in a supremely cohesive and intuitive API. So please give it a shot, let us know what you think on the mailing lists, and report any bugs you encounter (preferably with tested patches).

A note about this release candidate

We intend for Prototype 1.6.0_rc0 to be feature-complete, but we reserve the right to make adjustments to our new APIs and add or remove features before the final version is released.

Download

Download Prototype 1.6.0_rc0 Get Prototype help on the rails-spinoffs mailing list or #prototype IRC channel Interact with the Core Team on the prototype-core mailing list Submit bug reports to Rails Trac

Thanks to the many contributors who made this release possible!

Comments

Ben Alpert #

Looks great! Can’t wait for the stable version.

August 15th, 2007 @ 01:09 PM Les #

Looking great :)

Can you change a small code fragment in the fire: function(element, eventName, memo), so it can be safely compressed withe the Dojo compressor.

I know your code is valid but Dojo is not able to correctly compress it, see here:

http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/989d958ce6c30163/4933aef002c0cb71

and my comments on Ajaxian

http://ajaxian.com/archives/yui-compressor-the-latest-minification-tool

August 15th, 2007 @ 01:18 PM djib #

Great job! Those are many interesting new/updated features. Thanks.

August 15th, 2007 @ 02:28 PM Olli Puurunen #

Holy crap, great improvements! Keep up the good work!

August 15th, 2007 @ 03:31 PM Vince #

Great job! I love these new enhancements (specially custom events and support for inheritance and superclass methods).

Yeeehaa! You guys really rock!!

August 15th, 2007 @ 03:41 PM Kevin Miller #

WOW! It’s like you reached into my head and took my wishlist. 1.6 will allow me to rip out half of my helper functions I use! Keep up the great work guys!

Kevin

August 15th, 2007 @ 04:15 PM Philippe Meunier #

Oh yeah ! I think I will love those DOM manipulation methods !

But Les raise a concern because I used to compress prototype with Dojo ShrinkSafe (120kb uncompressed is kinda heavy). Hope this will be fixed in the next release candidate or the official release.

August 15th, 2007 @ 07:42 PM Adam Burmister #

Brilliant stuff!

I’m soo looking forward to the custom events and a replacement for my somewhat-iffy multiple-inheritance scheme. My widget library is in for some refactoring!

August 15th, 2007 @ 08:40 PM Justin Meyer #

Congrats! The events clean up looks great.

August 15th, 2007 @ 09:34 PM Jim #

I cant wait anymore. Please release the stabilized version asap.

Really interesting.

August 15th, 2007 @ 09:40 PM Faheem #

Really Cool!

Good work, more object oriented and more fun!

Thanks Guys

August 15th, 2007 @ 11:59 PM Nicolás Sanguinetti #

Yay! Finally :D

August 16th, 2007 @ 12:27 AM Alexey Bass #

Thanks for your great work! Can’t “breathe” without Prototype…

August 16th, 2007 @ 01:58 AM Stoor #

With this one can build great stuff!!

August 16th, 2007 @ 03:20 AM Thomas Fuchs #

For those who want to compress Prototype, have a look at our unoffical compressor. :)

August 16th, 2007 @ 03:48 AM Dean Edwards #

@Thomas – lol.

Also.

if (food instanceof Mouse) return $super();

Nice code. ;-)

Congrats on a great looking release.

August 16th, 2007 @ 04:01 AM Bobo #

Will script.aculo.us use element.fire for callback now, like:

var c = new Control.Slider(...) c.observe(‘update’, function(value) {...});

or is #fire not intended for this kind of use?

August 16th, 2007 @ 04:34 AM Rumble #

This looks like an excellent release. Several of the included enhancements are no-brainers and the new additions seem useful to me too.

Can’t wait to start playing around with this stuff!

August 16th, 2007 @ 04:41 AM Adam McCrea #

Thanks for this release, and the excellent write-up. Although it is a long article, I’m surprised to see the Form enhancements missing (especially Form.Element#setValue—that’s huge!). For those who don’t want to sift through the changelog, here ya go:

The action for Form#request defaults to the current URL if the “action” attribute is empty. (This is what most of the major browsers do.) Fixes #8483. [Tomas, Mislav MarohniÄ?]
In form serialization, change the way submit buttons are handled. Previously all submit buttons were serialized; now Prototype serializes only the first one. Change Form#serialize and Form.serializeElements to accept a params hash. With the “hash: false” option, a serialized string is returned instead of the hash data object. With the “submit: ‘foo’” option, only the submit button with the name “foo” is serialized. References #5031. [Mislav MarohniÄ?] Examples: $(‘form’).serialize({ submit: ‘delete’ }) $(‘form’).serialize({ hash: false }) //-> equivalent to $(‘form’).serialize()
Added Form.Element#setValue method for setting values on various form controls. Checkboxes and radio buttons respond to a boolean and multiple select boxes expect an array of values. Closes #5902. [Jonathan Viney, Mislav MarohniÄ?] Examples: $(‘text_input’).setValue(‘hello world!’) $(‘remember_me’).setValue(true) $(‘attend_classes’).setValue([‘cheese rolling’, ‘evil chemistry’])

Also notable (for me, at least) is the renaming of Element#getElementsBySelector to Element#select. It is still aliased for backward compatibility.

Other than that, I think you hit everything noteworthy. This is a fantastic release, and I can’t wait to start using it.

August 16th, 2007 @ 06:21 AM RStankov #

Super cool this release candidate will spare me a lot of time and coding

August 16th, 2007 @ 06:24 AM DK #

Wow! Great work!

I wonder why not a 2.0 release? New inheritance model was planned for this version AFAIK, and this is so big change of an API, that for me it’s a new era of Prototype. But, ... nevermind ;-) Can’t wait to start using it :-)

August 16th, 2007 @ 09:10 AM Julio Carlos #

I was looking for functionality of insertion long time ago, thanks for do it and do it just great. I loved those class api enhancements and the changes to Element.update and Element.replace

August 16th, 2007 @ 09:33 AM Ran Baron #

Wow! what an amazing release guys! I can’t wait to rewrite my apps with these new gems!

again, and as always, Thank you soooo much!

August 16th, 2007 @ 10:28 AM Thomas Fuchs #

@Bobo: Yes, I’m planning to support that, as time permits. Of course, I welcome any patches that make scripty use the custom events…

August 16th, 2007 @ 10:29 AM Prateek #

Hoooraa for Prototype!

August 16th, 2007 @ 10:34 AM youngbo Kim #

nice~, thanks for your endless development!

August 16th, 2007 @ 11:26 AM Vincent #

Woot, woot, completely awesome. Tonight, after work, I’ll check all those new stuff.

Great job guys!

August 16th, 2007 @ 11:37 AM Grant Hutchins #

Is there a centralized place where deprecations are reported? It might be helpful.

Something similar to http://rubyonrails.org/deprecation

Thanks for what sounds like a wonderful release!

August 16th, 2007 @ 12:15 PM Tobie Langel #

Grant: Very good point. We’ll try to add this to the documentation when 1.6 final is released.

August 16th, 2007 @ 02:36 PM Alex Egg #

I’ll assume that using new Element() automatically expands that element. Right?

August 16th, 2007 @ 03:38 PM Tobie Langel #

Alex: Obviously. And since we’re using a smart caching mechanism, this is actually much faster in IE than using document.createElement and extending elements yourself.

August 16th, 2007 @ 03:59 PM Alex Egg #

Look at the improved code using the DOM builder!

var catCell=new Element(‘td’, {className:’category’}).appendText(Category); item.appendChild(catCell);

As opposed to:

/var catCell=document.createElement('td');
catCell=$(catCell);
catCell.className='category';
catCell.appendChild(document.createTextNode(Category));
item.appendChild(catCell);/
August 16th, 2007 @ 04:01 PM Tino Zijdel #

I have mixed feelings about this release; the obsessive syntax sugaring seems to cause severe obesitas to the library itself which gained 27% weight compared to 1.5.1.1

My pet pieve at this moment is getElementsByClassName; I was glad that 1.5.1.1 solved the severe performance degradation in IE when using that method because of extending /all/ elements needlessly (although it still could be 3 times faster), but in this release this method seems to be 15% slower.

I’m glad you now don’t overwrite a native getElementsByClassName implementation, but you should bear in mind that there is a huge difference: native implementations return a live nodeList wereas a scripted implementation such as prototype’s returns a static array. That may well become a source of bugs.

Also I don’t know yet what to think of the improved Event API; I generally dislike implementations that still use IE’s broken eventmodel through wrappers (and without further fallback exclude some browsers). I already see a bug there: the W3C event model ignores a handler when it is already attached to the same event on the same element, IE’s model doesn’t (YUI has/had? the same bug)

August 16th, 2007 @ 05:14 PM Sam Stephenson #

Hi Tino-

If by “obsessive syntax sugaring” you mean the functionality we added in this release, then yes, it did come at the cost of more code. But Prototype 1.6.0 is just 28 kb when gzipped. I’d hardly call it “obese.”

We’re aware of the issue with getElementsByClassName returning NodeLists in Firefox 3 and hope to have it addressed before the final release. And we’ll certainly consider any patches to improve our implementation’s performance.

Finally, Prototype’s event API prevents registering the same handler multiple times on the same element. If you have specific issues with our event system in Internet Explorer, please file them on Trac (preferably with a tested patch).

August 16th, 2007 @ 06:21 PM Tino Zijdel #

Sam: I’m not a user of your library so I think it is impropriate to ask of me to supply patches. And yes, I call 28KB gzipped obese because most users won’t use more than 10% of what your library provides. In fact I only use (my own versions of) Object.extend and Function.prototype.bind and I call the rest irrelevant.

I’ll do some more testing with this eventsystem when I feel like it.

August 16th, 2007 @ 07:05 PM Nick #

Thanks for the hard work guys :)

Tino, if you are not using prototype you should stop whining about it. Keep using your own code if that works for you.

August 16th, 2007 @ 07:25 PM Webmaster Mexico #

Wow! thanks for this realase, I’m starting to change some parts of my code. Congratulations from Mexico.

August 17th, 2007 @ 12:00 AM Tuan #

Darn, there goes all my time extending prototype.

August 17th, 2007 @ 03:32 AM Jimbo #

thanks for good work, already like this :)

Tino: it’s a your problem, that you does not need and use all prototype.js posibilities. i need them and use, and those 28 or even 100kb is not problem for me, because it reduce code i write.

August 17th, 2007 @ 04:21 AM Viktor Kojouharov #

I’m glad to see that request aborting has been fixed.

Now all that’s missing is mouse(enter|leave|wheel) events :)

August 17th, 2007 @ 06:27 AM Tino Zijdel #

Sam: indeed the eventsystem won’t allow duplicates, it wasn’t clear to me at first what ‘pluck’ was doing and frankly doing this check inside createWrapper seems like an odd place.

Maybe that’s my main concern: I see prototype more and more using it’s own idioms instead of building upon javascript and DOM itself. Why not implement String and Array generics? Why not extend addEventListener to elements (since you do that for other properties and methods anyway)?

As for the people that feel that I’m whining: I take an interest in prototype because I take an interest in javascript and webdevelopment as a whole. I’m not saying prototype is irrelevant, I just don’t have a need for it myself. I think prototype is a beautiful piece of work and it often gives me new insights and inspiration, but at the end of the day I like to do things my way (like most programmers I have a big ego as well :P)

When time permits I might dive somewhat deeper into this release candidate and report any issues I may find. I’m uncomfortable though with the thought of having to create patches, I’m afraid my ideas about certain approaches might just be too different.

August 17th, 2007 @ 07:27 AM Les #

Prototype 1.6 RC0 in action :)

http://www.slippymap.com

Thanks!

August 17th, 2007 @ 08:06 AM Kroc Camen #

@tino: But in some cases almost all of the functionality is used. I’ve been able to refactor my code constantly to integrate tighter with Prototype and it’s had all round benefits.

I’ve also got compression down to an art form, through various techniques. In my project, I’m compressing 320K in 12 files down to 88K in 2 (77K if I use Packer 3.1a) – that’s with Prototype and Scriptaculous Effects inside that! Click my name to check out my Prototype project

August 17th, 2007 @ 10:28 AM Les #

Scriptaculous is still not friendly to Packer. I used the latest version 3.1a2 and got lots of missing semicolon errors.

Good thing: I encountered no problems with the latest Prototype and the latest Packer.

August 17th, 2007 @ 01:49 PM Paul Thrasher #

I’d argue that Tino’s comment is a lot more helpful than all those that just say “great job guys!” I’d love to hear more reasons why things don’t work and how it can be done differently, if not better. The more constructive feedback, the better. Let’s please not scare away all the people that just want to help out!

With that said… Great job guys! ;)

I’ll be implementing this as soon as possible into our dev environment here. I’m a little worried about breaking old projects so I’ll probably wait until the official release.

August 17th, 2007 @ 03:34 PM Andrew Dupont #

@Tino: We welcome feedback, especially when it’s offered so politely and eloquently. To address your two main points:

Most of Prototype’s idioms are influenced by Ruby, and those that have no analog in Ruby defer to existing or emerging web standards. (Note, however, that there were a handful of canonical getElementsByClassName implementations before WHATWG and Mozilla tackled the issue.)

We have lively discussions about naming schemes, argument positions, and the like. We look for prior art, but if there is none then we just do what feels right. We aren’t intentionally mavericks with our API, but then we aren’t aiming to emulate the full DOM API in all browsers (like, for instance, Dean’s base2 library).

Arguments over file size, in my experience, tend to end the same way as language wars. We’ve all got different thresholds for acceptable file size; they’re influenced by what we build and the breadth of our needs. If you wouldn’t use 95% of the Prototype codebase, then 28kb is definitely too large for you. Luckily, frameworks come in all shapes and sizes. Dan Webb’s Scripting Essentials and Robert Nyman’s DOMAssistant are two of my favorite mini-libraries.

If you’d like to continue this discussion, you’re welcome to post on the prototype-core mailing list. Discussion of the framework’s guiding philosophy is welcomed, especially now that a faint outline of Prototype 2.0 is visible in the distance.

August 18th, 2007 @ 12:22 AM Kroc Camen #

@Les: I get around the problem by running the code through DOJO’s compressor (custom_rhino.jar) which uses the RHINO engine to re-interpret the script and output valid code that will pack correctly. Yahoo have released YUICompressor which works the same as custom_rhino.jar.

If you run code through the DOJO compressor and then Packer, you’ll get an increased compression rate over just using Packer alone

August 18th, 2007 @ 03:14 AM huangam #

Cool work!:) _

August 18th, 2007 @ 10:16 AM Jack #

I think Prototype’s license term should be revised since the Creative Commons license under which the documentation is released is clearly incompatible with the MIT license that states:

” Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: ... “

i.e., the documentation is clearly stated as being part of the Software, and is hence distributed under the MIT license as well, overriding what the CreativeCommons license might say !

August 19th, 2007 @ 12:13 PM Sam Stephenson #

“Associated documentation files” covers the documentation that is stored in the source repository and distributed with Prototype itself, namely CHANGELOG, README and LICENSE.

The documentation on this site is not distributed with Prototype and is not subject to the MIT/Prototype license.

August 19th, 2007 @ 01:35 PM Ben Alpert #

If you don’t want to use gzip, then YUICompressing gives a size of 76KiB.

August 19th, 2007 @ 02:26 PM Nico Simonnet #

Yeah, seems really great! Cool inheritance system, gread DOM methods, no more of the diabolic binding in event observers…

I’m checking this right now!

Thanks for this great job, guys :)

August 20th, 2007 @ 05:15 AM Delmar Hager #

Thanks for adding before and after methods. This finally makes it easy to do what I use to do in LISP all of the time.

I often wondered about all of the rage about Aspect programming when I did this type of programming 18 years ago in LISP. As Solomon of old stated: “There is nothing new under the sun”

August 20th, 2007 @ 06:24 AM Tomasz Gorski #

Really great improvements! Keep up the great work. Regards

August 20th, 2007 @ 08:18 PM azar #

I like the inheritance.

Thanks for effort.

Azar

August 21st, 2007 @ 03:04 PM Sebastian #

I can’t wait for trying the new inheritance possibilities. Your crossbrowser event-handling saved me a lot of work !

Thanks for this great work !

Sebastian

August 21st, 2007 @ 03:56 PM Michael #

Looks like a minor bug in an example above:

Under “Prototype now boasts a new cross-browser DOM Builder” the result should be

input name=”user” disabled=”true”

not

input name=”user” disabled=”disabled”

right?

August 22nd, 2007 @ 12:06 AM Tobie Langel #

Michel: that example is correct, and that’s the way XHTML expects it too.

August 22nd, 2007 @ 02:03 AM arty #

Great work! Thanks!

I have two comments though.

First one is about #prototype channel. Main page of prototypejs.org suggests to join it on IRC, however I wasn’t able to find this channel on freenode. Does it exists?

Second is about ‘new Element()’. This is very similar to Builder.node() of script.aculo.us. I recently suggested this improvement for it: http://dev.rubyonrails.org/ticket/9213 I think it may be easily implemented in ‘new Element()’ too. Please : )

August 22nd, 2007 @ 03:35 AM Joao Pedrosa #

Prototype has matured is all I can tell! :-)

A few months back I tried it a little bit and didn’t find it all that good, but now I am giving it a real shot by slowly adopting it within my own framework. I like that I can share matters with Prototype, and while Prototype comes with a little over 4000 lines including comments and blank lines, my own framework was over 7000 lines already, so I don’t think Prototype is too bloated. Actually, I like that Prototype doesn’t go to extremes to save code. I for one prefer its code base over other competitors’ ones.

Also, I like that Prototype seems to be hacked by more than one person, as it shows some maturity.

All in all, I want to see whether I can adopt the new class style provided by Prototype because by the looks of it I like it.

Thanks for it and keep it up!

August 22nd, 2007 @ 08:23 PM Grady Kuhnline #

With regards to Prototype’s size and Tino Zijdel’s comments, I see this as a major concern, just behind performance. I have been implementing Prototype on some high-traffic sites and there are some significant concerns.

As a technology manager, I have to justify the use of prototype.js in our company. The fact that prototype.js comes with such a large footprint is significant commitment. I am constantly battling with “we only use 10% of the features and it has a huge footprint.”

It is getting to the point where prototype should be available in multiple versions: a) Vanilla kitchen sink b) Kitchen sink + Obfuscation (reducing size by over 30%) c) Ala Carte, removing some lesser used and non-essential features d) Ala Carte + Obfuscation

My notes about Shrinking sizes: 1) Gzip is not always available on the server, and doesn’t work in all browsers. This would lead to some poor sucker on an old/simple browser or a cheap web host getting the full 120KB.

2) Gzip is able to compress Prototype.js by 72.5% (33KB with GZIP level 3)

3) Using something like JSmin-php (http://code.google.com/p/jsmin-php/) before-hand will squeeze out an additional 5% (27KB with GZIP level 3 and JSMin-php).

3) JSMin all by itself reduces the the file size by 22.5% (93KB with JSMin-php).

August 22nd, 2007 @ 09:15 PM Su_cn #

Happy to see the new Event implementation of Prototype, then it is too much complicated, especially in ie modify ie event modal quite a lot, and new Function.prototype, add much more methods on it, maybe 1.60 needs much more testing. And in ie6 I have seen a error when I include the rc0 file, I really want the Event part to be as simple as in the 1.5.1.1 version

August 23rd, 2007 @ 09:21 AM Ash #

Good set of features.

August 23rd, 2007 @ 09:22 AM Su_cn #

For the differences between the nodeList and Array, because the nodeList is dynamically recreated, and Array is statically linked, so maybe this code can help to wrap the native getElementsByClassName document.getElementsByClassNameTemp=document.getElementsByClassName; document.getElementsByClassName=function(){return $A(document.getElementsByClassNameTemp(arguments0))}

August 23rd, 2007 @ 10:25 AM Adam van den Hoven #

Good work guys. I especially like the addition of curry to Function. I suspect that many people have no idea how to use curry, so I wrote a blog post (my first post ever!) on why and where you would want to use it. Go have a look http://starkravingcoder.blogspot.com/2007/08/curried-what-now.html

August 24th, 2007 @ 02:16 AM Daniel Stoichev #

10x for updated it really clean a lot of my code :)

But If it is possible to change the $A function too with this kind of hack : http://www.danwebb.net/2006/11/7/a-low-down-dirty-goblin-of-a-hack

so it can become something like that:

function $A(iterable) { if (!iterable) return []; if (iterable.toArray) return iterable.toArray(); return Array.prototype.slice(iterable, 1); }

because it’s one of most used in the framework among $, Object.extend, Function.prototype.bind

p.s. sorry if this issue is not for here

August 24th, 2007 @ 06:36 AM Lette #

I started using Prototype earlier this year after poking around at the other JS frameworks. While there are many reasons for sticking with it, the thorough and easy to navigate documentation has definitely been high on the list. Can’t wait to test out the new features, nice work!

August 25th, 2007 @ 02:20 PM Atit Shah #

I have one AJAX functionality in which on selecting value from one drop down my second drop down is getting changed. This things works fine in Firefox but when I am trying this in IE 6.0 it does not populate the data all time.I am using observe_field funtion for this. Now I was using Prototype.js version – 1.5.1_rc4. Now I have replaced my Prototype.js with this 1.6.0 candidate version but still It has not solved my problem. Can anyone suggest me what changes I should made? Thanks in advance for help

August 28th, 2007 @ 05:00 PM Jena #

Can’t wait for the stable version!!

August 28th, 2007 @ 10:19 PM Andrew #

Great work! I translated some self-controls into my Russian blog.

August 29th, 2007 @ 05:06 AM James And Yev #

OMG! We can’t wait to use this! This was exactly what we needed. Thanks team!

August 29th, 2007 @ 11:57 AM Daniel #

nice job!

thx for this awesome framework :)

August 29th, 2007 @ 04:58 PM Andrea #

Great work, you’ve really put fun into javascripting! thanks a lot.

August 30th, 2007 @ 09:19 AM choncon #
i using prototypejs and very amazing. this is old idea but i still want to ask everyone: why the property [b]each[/b] of Array object hasn’t many arguments.
I want to find some javscript code or applications which used prototypejs but where location ?
Sorry because my English bad.
September 1st, 2007 @ 08:12 AM Tobie Langel #

chonchon: I’m not sure I understand your first question properly. Maybe you should check the API documentation for Array#each and Enumerable#each to help you understand better what this method does.

Regarding applications which use Prototype, I suggest you have a look at our Who’s using Prototype page.

Hope this helps.

September 1st, 2007 @ 09:03 AM choncon #

thank comment the link : Who’s using Prototype are only websites of some companies or groups .I want to say about a page where everyone shares javascript codes within prototypejs. Example: Menu_Drop_Code

September 1st, 2007 @ 02:02 PM choncon #

oh i forget I didn’t found anything about COOKIE in prototypejs .why ?

September 1st, 2007 @ 02:06 PM Bob #

Hi, i know this ain’t the place to do this, but i’m a bit to busy right now to install a version manager..

I wanted to report that in IE7 the gif text on this website, which is supposed to hover over the ‘blue part’ of the site, is not hovering over the blue part, but just below it..

Thanks for all the effort you guys put into pushing javascript to the next level!!

B.O.B.

September 4th, 2007 @ 03:46 AM Raul #

Can you add some feature to the Event object to handle(enable/disable?) event bubbling? Don’t know if this is possible but is an issue that’s biting my right now.

September 4th, 2007 @ 11:24 AM Alexander #

Thanks for awesome framework, and please consider: why not make Enumerable.empty() property?

September 4th, 2007 @ 02:00 PM Markus #

would be nice to have a cross browser methdod for retrieving the activeElement, e.g:

IE document.activeElement FF event.explicitOroginalTarget ...

September 5th, 2007 @ 04:52 AM I want only test #

I want only testI want only test

September 5th, 2007 @ 12:09 PM Bas van Gaalen #

Looking quite cool, great update. What about a timeout setting for Ajax?

September 6th, 2007 @ 04:03 AM Prodotti Tipici #

I’m waiting to try this new release.

September 8th, 2007 @ 01:01 PM Addict #

I just download it and hmmm it quit egood thsx

September 8th, 2007 @ 08:42 PM Porfirio #

Hi, i love the new Class systemi have some sugestions thought…

1. Make it possible to use MyClass = Class(...) also

2. Would be cool to be able to do this:

var Test=Class({ name:”Dunno”, initialize:function(name){ this.name=name; } }); var Test2=Class(Test,{ name:”Porfirio”, initialize:function($super,name){ alert($super.name); //wish will give me “Dunno” } });

September 10th, 2007 @ 06:05 AM Brian Edwards #

It says…

document.observe(“contentloaded”, function() { ... })

I had to do…

$(document).observe(“contentloaded”, function() { ... })

September 10th, 2007 @ 04:11 PM Alex #

The html element creation stuff is a good start – but this really needs to go further for it to be really useful. How about just a special attribute { “_text” : “this is a new text node” } that appends text into the element?

September 11th, 2007 @ 11:30 AM Conan #

Great work on the API chaps, and I agree with Mr. van Gaalen on a timeout setting for Ajax.request. (Incidentally, loved GFXFX2. ;-)

September 13th, 2007 @ 02:05 PM Steven Moberg #

Did you know that Prototype.js can be configured for Server Side JScript (ASP).

I have removed the window/dom references from prototype_1.5 and added an Event.observeMethod which works alot like the Function.prototype.wrap

I’ve also added added an fromASP method to convert Request objects to Hash objects.

var Form $(Request.Form);

I’ve also added a newObject method to create new JScript objects from VBScript.

Dim jsArray Set jsArray = newObject(“Array”); jsArray.push(stuff);

Would this be something you would be interested as developing for the unfortunate ASP community? It would bring Ruby Styling to the a whole new market.

September 13th, 2007 @ 09:52 PM

Sorry, comments are closed for this article.

Search Blog


Search the prototype blog.

Subscribe to the blog

Akismet badge


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser