$async is available on NPM as and as a PHP Composer package.

Install via NPM

npm install --save


Install via PHP Composer

composer require styletools/async



$async is modular and easy to use: select only the features that are needed to achieve the tiniest script size.

  • simply stitch pre-optimized GCC modules together for a performant IIFE. You can wrap the modules in dist/ into an IIFE, e.g. !function(){/* stitched modules */}();. Follow the module order in package.json.

  • Online IIFE generator (adds an extra GCC Advanced mode compression layer)

  • Node.js/CLI IIFE generator (adds an extra GCC Advanced mode compression layer)

  • PHP IIFE generator (available on request: [email protected])

IIFE Generator

$async IIFE generator enables to easily create a pre-concatenated selection of $async modules that is additionally optimized using Google Closure Compiler.

The IIFE generator is available online on


npm install

Module concatenation: select only what you use

$async is compiled into modules via Google Closure Compiler that does not just compress javascript but also optimizes it for speed.

The Google Closure Compiler module architecture enables to concatenate a selection of $async modules without the use of a module loader. You can simply wrap the module source text in a IIFE and include it safely in the HTML document.

Example: Pre-concatenated file

<script async src="js/async-iife.js" data-c='[
"href": "",
"render_timing": "requestAnimationFrame"

Example: Inline concatenation

// include a selection of $async modules inline
echo "<script>(function(){"; // wrap in IIFE
readfile('vendor/styletools/async/dist/cache.js'); // cache module
readfile('vendor/styletools/async/dist/localstorage.js'); // localStorage module
echo "})();</script>";