SOURCE CODE: JavaScript Scruncher

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
  <title>JavaScript Scruncher | JavaScript Tools | UIZE JavaScript Framework</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="keywords" content="tool Uize.Build.Scruncher"/>
  <meta name="description" content="Take bloated JavaScript source code and scrunch (minify, compress) it using this versatile tool. Drastically reduce its size and even obfuscate it!"/>
  <link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href=""/>
  <link rel="stylesheet" href="../css/page.css"/>
  <link rel="stylesheet" href="../css/page.example.css"/>
  <link rel="stylesheet" href="../css/widget.tabs.css"/>
  <link rel="stylesheet" href="css/tabbed.css"/>


<script type="text/javascript" src="../js/Uize.js"></script>

<h1 class="header">
  <a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
  <a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>

<div class="main">
  <h1 class="document-title">
    <a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
    JavaScript Scruncher
    <div class="pageActionsShell">
      <div id="page-actions" class="pageActions"><a href="source-code/javascript-scruncher.html" class="buttonLink">SOURCE</a></div>

  <!-- explanation copy -->

  <div class="explanation">
    <p>The <b>JavaScript Scruncher</b> tool (which makes use of the <a href="../reference/Uize.Build.Scruncher.html"><code>Uize.Build.Scruncher</code></a> module) lets you test the scrunching of JavaScript code. Paste some JavaScript into the <b>"SOURCE CODE"</b> tab and then switch to the <b>"SCRUNCHED CODE"</b> tab to see the scrunched version. Switch to the <b>"SCRUNCHER REPORT"</b> tab to see a summary of the file size savings for different facets of the scrunching operation. To start you off, the <b>"SOURCE CODE"</b> tab is set up with the contents of a Uize module. To learn more about how the scruncher works and the options available, consult the guide <a href="../guides/all-about-scrunching.html">All About Scrunching</a>.</p>

  <div id="page_tabs" class="tabShell">
    <div class="tabStubShell">
      <a id="page_tabs_option0" class="tabStub" href="javascript://">SOURCE CODE</a>
      <a id="page_tabs_option1" class="tabStub" href="javascript://">SCRUNCHED CODE</a>
      <a id="page_tabs_option2" class="tabStub" href="javascript://">SCRUNCHER REPORT</a>
      <br style="clear:left;"/>
    <div class="tabBodyShell">
      <div id="page_tabs-option0TabBody" class="tabBodyInactive">
        <textarea id="page-sourceCode" wrap="off"></textarea>
      <div id="page_tabs-option1TabBody" class="tabBodyInactive">
        <textarea id="page-scrunchedCode" wrap="off"></textarea>
      <div id="page_tabs-option2TabBody" class="tabBodyInactive">
        <textarea id="page-scruncherReport" wrap="off" readonly="readonly"></textarea>

<script type="text/javascript">

Uize.require (
  function () {
    'use strict';

    /*** create a page widget subclass ***/
      var CustomPageWidget = UizeSite.Page.Example.subclass ();

      /*** add property for managing update of scrunched code and scruncher report ***/
        CustomPageWidget.stateProperties ({
            onChange:function () {
              var scruncherResult = Uize.Build.Scruncher.scrunch (this.sourceCode);
              page.setNodeValue ('scrunchedCode',scruncherResult.scrunchedCode);
              page.setNodeValue ('scruncherReport',;

    /*** create the example page widget ***/
      var page = = CustomPageWidget ();

    /*** add the tabs child widget ***/
      var tabs = window.tabs = page.addChild (
      tabs.wire (
        function () {
          var tabsValue = tabs + '';
          if (tabsValue == 'scrunchedCode' || tabsValue == 'scruncherReport')
            page.set ({sourceCode:page.getNodeValue ('sourceCode')})

    /*** make the scrunched code and scruncher report textareas select all when clicked ***/
      page.wireNode (['scrunchedCode','scruncherReport'],'click',function () { ()});

    /*** wire up the page widget ***/
      page.wireUi ();

    /*** initialize sample data ***/
      page.setNodeValue ('sourceCode',UizeSite.Templates.JavaScriptSourceSample.process ());