Java Reference
In-Depth Information
The final two additions are familiar to you; the first creates a custom Modernizr test called
draggable :
Modernizr.addTest('draggable', function () {
var span = document.createElement("span");
 
return typeof span.draggable != "undefined";
});
The second calls Modernizr's load() method to load the necessary polyfills if they're needed:
Modernizr.load([{
test: Modernizr.draggable,
nope: "draggable-polyfill.js"
},
{
test: document.addEventListener,
nope: "event-polyfill.js",
complete: init
}]);
We should admit that, in the case of this example, creating the custom draggable test is a bit
overboard. You only use the test once, so it would be slightly more efficient to omit the custom test and
write the first yepnope object like this:
{
test: typeof document.createElement("span").draggable != "undefined",
nope: "draggable-polyfill.js"
}
At the same time, this slightly more efficient version is a bit uglier. Ultimately, the choice is yours.
In cases like this, however, many people create the custom test in a utility file because it could be
reused in other projects.
diving into prototYpe
jQuery is the most popular framework today, but that crown used to sit upon Prototype's head.
Unlike jQuery, Prototype's focus is augmenting the way you program with JavaScript by providing
classes and inheritance. It does, however, also provide a robust set of tools for working with the
DOM and Ajax support.
getting prototype
Point your browser to Prototype's download page at http://prototypejs.org/download . Here,
you'll be given the choice to download the latest stable version, or an older version. The examples in
this topic use the latest stable version at the time of this writing: v1.7.2.
 
Search WWH ::




Custom Search