Javascript compressor - Example of correct terminated code

The packing algorithm is forgiving of all forms of JavaScript with one exception. You must correctly terminate all JavaScript statements with semi-colons. This includes function declarations.

Here is an example of correct, semi-colon terminated JavaScript:

// sample code

var $input, $output;


// notice the semi-colon at the END of function declarations


onload = function() {
    $input = document.getElementById("input");
    $output = document.getElementById("output");
    _clearAll(true);
};



function _packScript() {
    $output.value = pack($input.value);
};

function _clearAll($focus) {
    $output.value = $input.value = "";
    // the "if" statement is NOT terminated with a semi-colon
    if ($focus) {
        $input.focus();
    }
};

Example borrowed from algorithm author Dean Edwards.

<- Back to Javascript Compressor