npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

asset-warmer

v0.0.5

Published

Script for preloading website with percentage progress.

Readme

Asset-warmer

npm version

This package helps to show percentage loader for SPA websites while loading core assets.

Websites build on frameworks like Angular or Vue tend to have pretty big javascript or even css files.

When creating SPA website in most cases we want to show loading screen and when assets (main js/css files) are downloaded we showing our entire web app.

This package helps You to show you progress (%), what kind of file now its downloading etc. and make loading screen more lively.

Its really helpful for visitors with slow internet connection because they will see real progress of site being loading for sure.

Demo

https://kiberzauras.github.io/asset-warmer/

Requirements

  • required Assets must be in the server where CORS enabled (You must be able to make ajax request to it). (localhost works, most of cdn also).
  • optional Server should return Content-Length header of assets for better warmer experience. If You unable to use it, You will be able to write asset size manualy or use progress events without total size (percentage).

Installing

Using npm:

npm install asset-warmer --save-dev

Using bower:

bower install asset-warmer

Using cdn:

<script src="https://unpkg.com/[email protected]/asset-warmer.min.js"></script>

Usage

It would be best if you would use cdnto add reference to it by script tag:

<body>
	...
	<script src="https://unpkg.com/[email protected]/asset-warmer.min.js"></script>
	<script>
	 new Warmer(['jquery.min.js', 'app.js']).on('update', function(e) {});
	</script>
</body>

But you can use npm if needed.

const Warmer = require('asset-warmer');
new Warmer(['vendors.js', 'extenstions.js', 'app.js']).on('update', e => {});

Just keep in mind that adding this package to your main javascript bundle doesnt make sense.

You need to make another small bundle with asset warmer add it to your index.html file and remove all other assets from it. (leave them only in warmer array - it will be downloaded and appended).

Initialization

If you want to warm-up single file just run:

var warmer = new Warmer('app.js');

You can also pass array of files:

var warmer = new Warmer(['app.js', 'app.css', 'images/logo.png']);

If you will be showing which file is warming up, you can also pass files as objects with custom names:

var warmer = new Warmer({src: 'app.js', name: 'Core website'});

You can also pass objects in arrays, even mix them together when just strings of filepath.

var warmer = new Warmer([
    {src: 'app.js', name: 'Core website'},
    'images/logo.png',
    {src: 'app.css', name: 'Stylings'}
]);

File object requires only src parameter, if name is missing, system will create one from src. You can also pass size to set filesize in bytes, if package will not be able to retrieve it from server.

Events

Update event, shows entire progress of assets.

var warmer = new Warmer('app.js');
warmer.on('update', function(e) {
  console.log(e.type); //asset_progress, asset_loaded, asset_failed,  
  console.log(e.file.name);  
  console.log(e.file.src);  
  console.log(e.file.percentage);  
  console.log(e.file.loaded);  
  console.log(e.file.total);  
  console.log(e.file.knownSize);  
  console.log(e.progress.bytes.loaded);  
  console.log(e.progress.bytes.total);  
  console.log(e.progress.bytes.percentage);  
  console.log(e.progress.files.loaded);  
  console.log(e.progress.files.loading);  
  console.log(e.progress.files.total);  
  console.log(e.progress.files.percentage);  
  console.log(e.result);  
  console.log(e.event);  
  console.log(e.errorType);  
});

After all assets loaded, warmer will fire finished event.

warmer.on('finished', function(e) {
    //e contains array of files
});

Warmer also fires asset_appended and appended (for all) after assets are appended to DOM.

Options

You can pass options to second parameter of Warmer function. By using options you can disable default behaviour such as auto asset appending to DOM.

var options = {
    appendWhenDone: false
};
var warmer = new Warmer('app.js', options);

| Options | Description | | ------------- | ------------- | | preFlight |Sends HEAD request to get filesizes before starting downloding. Usefull when axact percentage of couple of assets needed. Do not use it if loading only one asset. Loading too many files because this will make more request and retrieve assets slower. Think if you really want excat percentage of downloads or can show only downloaded bytes etc. Default is false. | | appendWhenDone | Automatically append js/css assets to dom head tag after ALL of assets are retrieved. Default is true | | appendAtOnce* | Automatically append js/css assets to dom head tag at once when asset is retrieved. Default is false | | appendStyles | Automatically append css assets to dom tag. Default is true. appendWhenDone or appendAtOnce must be true. | | appendScripts | Automatically append js assets to dom tag. Default is true. appendWhenDone or appendAtOnce must be true. | |byOrder*|Retrieves and appends assets in order given. Default true|

Options marked with * are non existing features in current version.

How it works?

  • You pass array of assets to warmer in order needed.
  • Warmer one by one will retrieve assets needed and load it to browsers memory.
  • Warmer will send update event every time it will download some of asset.
  • You can use event to change loading screen as you like with got data.
  • When all assets retrieved, and there is css or js files in them - warmer will append them to the end of documents head tag.

NPM NPM