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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fireball-js

v1.1.5

Published

Breakpoints for performance

Downloads

22

Readme

Fireball

Breakpoints for performance.

Fireball is a small script that runs when your web page is loaded. It generates a score based on the performance of the user's hardware.

It hands off the work to a different thread so won't slow the rest of your site down while it's running.

Installation

npm install fireball --save
bower install fireball

Example usage

Setup

Fireball uses a Worker to calculate a score, which is loaded dynamically when fireball initialises. No need to host the worker script in another file.

Running fireball, the simple way

var Fireball = require('fireball-js');
Fireball.run();

or if adding the script directly or using bower Fireball will be already available:

Fireball.run();

The resulting score will be available in your JavaScript as Fireball.getScore() after a few seconds.

if (Fireball.getScore() > 8000){
    //Do something to delight the user
} else {
    //Do something boring but easy on the CPU
}

Running fireball with classes

Fireball.run({
    speedRanges: [
        {min: 0, className: 'speed-of-sloth'},
        {min: 4000, className: 'speed-of-tortoise'},
        {min: 8000, className: 'speed-of-puppy'},
        {min: 16000, className: 'speed-of-cheetah'}
    ]
});

These breakpoints will be added as classes to the <body> so you can target them in CSS. E.g.

body.speed-of-sloth .my-element {
    /* no box shadows, transitions, etc. */
}

body.speed-of-cheetah .my-element {
    /* some hella fancy animation */
}

Running fireball with all the bells and whistles

Fireball.run({
    debug: true, //shows an onscreen readout. Defaults to false
    runs: 7, //defaults to 7
    defaultScore: 5000, //defaults to 0
    classEl: 'body', //append a class indicating speed to this element. Defaults to 'body'
    speedRanges: [ //the speed breakpoints and classnames to use
        {min: 0, className: 'sloth'},
        {min: 4000, className: 'tortoise'},
        {min: 8000, className: 'puppy'},
        {min: 16000, className: 'cheetah'}
    ],
    callback: function(score) {
        //do something now that the tests are done
        //  or store the score in a global variable if you're that way inclined
    }
});

You can also register a callback like so.

Fireball.onSuccess(callback);

callback will be passed a single argument, the score.

This is handy if you have a modular system and want to access the fireball score in a different module without using a global variable. If the score has already been calculated this will execute immediately.

Browser support

Chrome, Firefox, Safari, Android 4.4+.

Won't work in the current IE (11) or Edge (25).

Benchmark

The Fireball score is roughly aligned with the Octane benchmark score; if a machine gets 15,000 on octane, the Fireball score will be within a few thousand of that. Probably.

Check out the demo on my site to see what score your machine gets.