I consider myself humbly fortunate to have been added as a member of Prototype’s new core development team. My first patch: optimizing getElementsByClassName. Browsers with XPath support get an eightfold performance gain; others get a modest gain of 50-100%.
Category: JavaScript
Sep13
Sep9
Viewport Dimensions in JavaScript
Adapted from the functions posted on QuirksMode.
var Client = {
viewportWidth: function() {
return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
},
viewportHeight: function() {
return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
},
viewportSize: function() {
return { width: this.viewportWidth(), height: this.viewportHeight() };
}
};
Sep5
Prototype 1.5.0 has a new release candidate. New stuff since my last post: awesome DOM navigation via Element.(up|down|next|previous), Array.uniq, and a few bug fixes. There’s some more cool stuff in the pipeline.
Aug30
A smorgasbord of commits to the Prototype SVN repo, after four months of inactivity. Method chaining, new Element.Methods, object cloning, and this patch I wrote a while back. This is a meat-filled and much-needed update.
Aug23
Freshen up your JavaScript, a presentation given by Sam Foster and me at the Refresh Austin meeting earlier this month. If you’re in Austin and you’re reading this blog, you probably ought to be a Refresh member.
Iterators in JS 1.7: Cool stuff you can’t use yet
Today’s wonk porn is going to talk about iterators — one of JavaScript 1.7’s cool new features — and how it relates to polymorphism. Grab a recent nightly build of Firefox 2.0 in order to play along.
Enumerables and Polymorphism
In Prototype, each Enumerable contains an _each method (note the underscore) that announces how it’s supposed …
Aug17
I’d welcome work on improving JavaScript as a language and browser implementations to support further application-controlled sandboxing and data hiding. The same-domain policy is far too coarse grained a solution for the applications we’d like to be able to write.
Aug15
Holy crap! The WebKit JS engine has matured by leaps and bounds since the last Safari release. I knew about XPath support, but not about getters/setters, direct access to DOM prototypes (which had been accessible in a convoluted manner), or XSLT. They claim it’s also 20-30% faster. I pray this stuff will make it into a Safari release that isn’t Leopard-only.
Aug10
ScriptDoc, an open standard being developed by the Aptana dudes (with help from John Resig of JQuery). JavaScript needs an authoritative documentation format, so if you’re a JS developer, sign up for the forums and start participating!
Jul10
More than you ever wanted to know about $$ and XPath
I took great interest in Sylvain Zimmer’s optimized version of Prototype’s $$ function, since I’ve been working on something very similar recently. Sylvain’s version uses more workmanlike string parsing; mine uses XPath. Each approach has its strengths and weaknesses.
The $$ function
For those unfamiliar with Prototype: the $$ function is used to perform DOM …