Deprecation.js: easing the 1.5 → 1.6 transition
If you’ve put off the task of upgrading your old code to Prototype 1.6, now you’re out of excuses. Core team member Tobie Langel has developed a script that will warn you of any deprecations or API changes.
The script is meant to be used with Firebug, so it’s Firefox-only — but when you’re done, your code will be ready for use alongside Prototype 1.6 in all browsers.

Using the script is easy. To migrate a page from 1.5 to 1.6:
- Find the
scripttag that referencesprototype.js. Change the path to point to the 1.6.0.2 version (or else overwrite the existingprototype.jswith the new version). - On the very next line, add a
scripttag that referencesdeprecation.js. - Develop your app as normal.
When your code calls a method that’s been deprecated, replaced, or modified, the script will log a warning or error to your Firebug console. Clicking its hyperlink will take you to the deprecation script itself, which isn’t all that helpful; but the message itself will contain a stack trace that points to the source of the error.
Naturally, the console errors are the most important to address, since they represent things that will no longer work in 1.6. The warnings represent deprecations — things that still work in 1.6, but are not guarateed to work in future versions of Prototype. If you’d like to see only removal notices, you can set a property in your code to turn off deprecations:
DeprecationNotifier.logDeprecation = false;
As you address these errors and warnings, they’ll go away. When there are no more errors, your code is compatible with 1.6. When there are no more warnings, your code is nimble and future-proof.
Sorry, comments are closed for this article.


Comments
...this is really helpful and useful, many thanks Tobie, appreciate it.
Very nice. I’m jealous when I see how you guys can write javascript code! So much to learn!
Note that I’d be interested in exploring the possibility of turning this into a Firebug extension.
If there’s anyone that would be interested in helping out with this, please step up!
Hi,
Do you have a sample page to test ?
I would like to check if the console feature is also working with Companion.JS that emulates “console.log” feature to IE (shoud be, but just to be sure).
Thanks.
@JFR: Unfortunately, the deprecation is Firefox only, not because it relies on Firebug… but because it’s using some advanced features of JavaScript, not yet implemented in IE.
Well, that’s bad :-(
Thanks for your answer.
JFR
Then you should have not probs upgrading prototypejs.org from 1.5 to 1.6 :-)
@Morten: Yeah, we’re just a busy bunch ;)
Thats cool any code that allows simple upgrade is always best.
Very nice. This is an awesome tool for upgrade that few open source library maintainers would actually take the time to bring up, Thanks Tobie !
Does this work with 1.4 to 1.6 migration as well? I inherited 1.4 and could not update before due to depency on old rico.js 1.1.3.
I looked at 1.5 documentation/release notes on possible migration help from 1.4 to 1.5; did not have much luck.
Now planning to update to latest version of prototype 1.6.02…any ideas/tips is greatly appreciated!!
@Randy: This should work to upgrade from 1.4 to 1.6 too. Please let us know how it goes.
Upgrade to 1.6 easilty and is working fine with FF2.0.
Having issues with IE 7 (specifically with Ajax updater). Any known issues/tips to deal with IE7?
Thanks for the update Randy!
Glad to know this helped you migrate from 1.4 to 1.6.
Regarding your specific issues, I think they’re best asked on the mailing list.
@Tobie Langel: Opera supports getters and setters and it’s equivalent to console.log is opera.postError. Why isn’t Opera supported?
Correction: Opera and Safari support getters and setters. Safari supports console.log however I’m not sure if the debug menu has to be enabled for this to function. Opera’s equivalent is opera.postError. The only thing unable to be supported should be IE.
@fearphage: I’m aware of that (except Safari 2 doesn’t support getters and setters). I wanted to get this out as soon as possible, and suspect the amount of developers using Opera/Safari as their main developing browser is pretty small. You’re more than welcome to post a patch though.
Really cool! Easy to use. :)
Sorry for question, but WHEN your API Documentation for prototype 1.6.0.2 will be done?
P.S. Great thanks for you work from Russia!)
@DS_tm: We’re currently busy writing a custom solution to embed the documentation as inline comments in the source code. You should hear more about this soon, so stay tuned.
@Tobie Langel: Oh, it’s a excellent idea! Good luck in your job guys.