Monday, February 4, 2008

YUI and Bookmarklets

I am a big fan of YUI (Yahoo User Interface) as it truly simplifies the cross browser implementation of JavaScript. In some ways it can be bulky, in some ways it's easier to implement my own light-weight controls... In other ways it has revolutionized the way I program JavaScript. Recently I came across one man's idea of implementing YUI everywhere you go. The idea is simple, add a simple script as a bookmarklet and you can utilize the power of YUI on anyones website!
The code is simple:

(function(){
var s = document.createElement('script');
s.src='http://yui.yahooapis.com/2.2.2/build/utilities/utilities.js';
document.getElementsByTagName('head')[0].appendChild(s);
})()


Once the script is run you can run additional scripts like:
var all = document.getElementsByTagName('*');for(var i = 0; i < all.length; i++) {new YAHOO.util.DD(all[i])}

Which will make all elements dragable, allowing you to mess with web pages in some pretty unique ways!

It is stuff like this that really makes being a web designer exciting!


No comments: