$async is available on NPM as @style.tools/async and as a PHP Composer package.
npm install @style.tools/async --save
Package: https://npmjs.com/package/@style.tools/async
composer require styletools/async
Package: https://packagist.org/packages/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: info@style.tools)
$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 https://style.tools/iife/.
npm install @style.tools/async-iife
$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.
<script async src="js/async-iife.js" data-c='[["css/sheet1.css",{"href": "https://cdn.com/css/sheet2.css","render_timing": "requestAnimationFrame"}]]'></script>
<?php// include a selection of $async modules inlineecho "<script>(function(){"; // wrap in IIFEreadfile('vendor/styletools/async/dist/async-core.js');readfile('vendor/styletools/async/dist/css-loader.js');readfile('vendor/styletools/async/dist/cache.js'); // cache modulereadfile('vendor/styletools/async/dist/localstorage.js'); // localStorage moduleecho "})();</script>";?>