Advice On Datejs Compression And Performance Tuning

January 22nd, 2008 | Code

Guy Fraser recently chronicled a series of his recommendations for Datejs compression and performance enhancements. Check it out.

One recommendation from Guy was to hold a reference to the Date.prototype in a local var, thereby saving characters and simplifying access to the prototype.

Example

(function () {
    // Store prototype in local variable making
    // syntax shorter and access faster.
    var $P = Date.prototype;

    // Old
    // Date.prototype.clearTime = function() {

    // New
    $P.clearTime = function () {
        this.setHours(0);
        this.setMinutes(0);
        this.setSeconds(0);
        this.setMilliseconds(0);
        return this;
    };
}());

After changing everything over we were able to shave a little over 1k off the total library size and our performance tests did register an improvement. Great advice, and Datejs is now better (and faster!).

All this has been checked into SVN for public consumption.

Ajaxorized Sliding Date-Picker

January 22nd, 2008 | News

SliderWillem from Ajaxorized has just glued together Prototype, Scriptaculous and Datejs to create a super cool sliding date-picker widget.

Check it out.