Advanced JavaScript is Fun
Daryl Koopersmith
So, what is this JavaScript?
Is it Java? Is it coffee? Can I drink it? Is it tasty?
JavaScript in WordPress
PHP: Builds the page.
JavaScript: Makes the page go.
The best way of discovering what JavaScript does for WordPress is to disable it.
We lose a few things…
Visual editor (TinyMCE).
Drag and drop.
AJAX.
Media.
Okay, so why you?
Menus – 3.0.
Internal Linking – 3.1.
GSoC – 2009 & 2010.
JavaScript is a wonderful language…
…when it’s used properly.
…and there are a lot of poor examples out there.
And it can do some pretty crazy things…
var obj = function( args ) {
if ( this instanceof arguments.callee ) {
if ( typeof this.init == "function" )
this.init.apply( this, args && args.callee ? args : arguments );
} else {
return new arguments.callee( arguments );
}
};
As developers, we sometimes lean on libraries.
And rightfully so. But we should understand how they work.
We use jQuery in WordPress.
You can do fun things, like sliding!
jQuery('.slide-away').slideDown();
…but how does it work?
It slides? Down? Uh, it slides. Things. Down. With magic.
jQuery is a black box of mystery and intrigue.
jQuery is not a black box of mystery and intrigue.
For the love of all that is good in the world, read the source.
But, but… what if I don’t understand the source?
There’s an easy solution.
Advanced JavaScript is Fun
Daryl Koopersmith