Monday, March 17th, 2008
I started ProtoSafe in response to a couple of posts on the Prototype Core Mailing list written by developers frustrated with Prototypeâ€™s 3rd party compatibility issues. I did some digging and found a post my Mislav Marohnic (here) explaining an easy way to keep Prototype out of the global namespace by simply wrapping everything in a self-executing anonymous function.
I asked John to explain the best use case for Protosafe and how it helps:
Prototype extends native data type prototypes which makes it very convenient for the developer but when interacting with 3rd party code not written for Prototype, these prototype extensions can cause compatibility issues. The most common is the Array for-in loop issue where by doing a for in loop over an array you get its indexed values plus the method names of all the added helper methods.
The benefit that ProtoSafe provides is that it allows Prototype to be used alongside 3rd party code without causing these compatibility issues.
Also it can be run against multiple frameworks which is good in the widget environment.
The demo page shows MooTools,Prototype,Dojo,YUI,jQuery all running on the same page.
Some highlights of ProtoSafe are:
- It allows Prototype to work with 3rd-party scripts (no Array for-in
- It works with Prototype 1.4-220.127.116.11.
- Custom Packer3 that supports Prototype 1.6+/Scripty 1.8.1+
- Only 3kb gzipped, less when compiled into the standalone js.
Posted by Rey Bango at 10:41 am