JavaScript

Increase revenue, productivity, and customer satisfaction/loyalty with 7x faster page load time. Decrease cost with 50% less bandwidth and energy.

 

How It Works

Each <script> element in the HTML output that contains a src attribute is replaced with the following:

<script [all attributes except src]>
eval(sc%1);
</script>

The content of the resource pointed to by the src attribute is added to a single consolidated resource:

var sc%1=’%2′;

%1 = a unique identifier
%2 = the content of the resource

Each <script> element in the HTML output that does not contain a src attribute is replaced with the following:

<script [all attributes]>
eval(sc%1);
</script>

The content between the start and end tag is added to a single consolidated resource:

var sc%1=’%2′;

%1 = a unique identifier
%2 = the content between the start and end tag

As a result, request headers and response headers are sent for a single consolidated resource instead of X (7 on average) number of resources.

Inline scripts are now external, thereby decreasing the size of the HTML output.

Compression of the single consolidated resource is greater due to the need for only one gzip or deflate wrapper instead of X (7 on average) and the likelihood of additional repeated strings, taking advantage of the dictionary that has already been created.

 

Whole Context Removed

Squash Compression is aware of what scripts the HTML output is referencing. Many times, modular development of scripts leads to having the HTML output reference an entire script resource even though only a subset of that resource may be used (such as a script function). Squash Compression does not transmit any script context that is not referenced by the HTML output.

 

Auto Minification

Squash Compression is aware of what extraneous formatting characters are needed by developers to maintain code, but not needed by user agents to display Web pages. Squash Compression does not transmit any extraneous formatting characters in the JavaScript output. As a result, you will never again need to transform your static content back and forth between human-readable and machine-readable formats; plus dynamically created resources are automatically minified.

 

Fine Tuning

In some cases, you may need to fine tune a page. Squash Compression allows you to enable/disable JavaScript processing at the page level and even at each <script> tag. Please help us make Squash Compression better by sharing with us any situations where you have to do this!

 

Enabling on a Web Page

You can enable JavaScript processing at the page level.

If you installed Squash Compression in “On” mode, there is nothing extra that you need to do.

If you installed Squash Compression in “Off” mode, then add the following at the top of the page (don’t worry, it won’t be emitted in the final output):

<!--sc_js_on-->

 

Enabling on a <script> Tag

If you need tighter control, you can enable JavaScript processing per <script> tag.

If you installed Squash Compression in “On” mode, there is nothing extra that you need to do.

If you installed Squash Compression in “Off” mode, then add the following attribute and value to the <script> tag (don’t worry, it won’t be emitted in the final output):

sc_js_on=”1″

For example:

<script type="text/javascript" src="scripts.js" sc_js_on="1"></script>

Or:

<script type="text/javascript" sc_js_on="1">…</script>

 

Disabling on a Web Page

You can disable JavaScript processing at the page level.

If you installed Squash Compression in “Off” mode, there is nothing extra that you need to do.

If you installed Squash Compression in “On” mode, then add the following at the top of the page (don’t worry, it won’t be emitted in the final output):

<!--sc_js_off-->

 

Disabling on a <script> Tag

If you need tighter control, you can disable JavaScript processing per <script> tag.

If you installed Squash Compression in “Off” mode, there is nothing extra that you need to do.

If you installed Squash Compression in “On” mode, then add the following attribute and value to the <script> tag (don’t worry, it won’t be emitted in the final output):

sc_js_off=”1″

For example:

<script type="text/javascript" src="scripts.js" sc_js_off="1"></script>

Or:

<script type="text/javascript" sc_js_off="1">…</script>