Category: JavaScript

link
6

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%.

code

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() };
  }
};