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

topmarks

v1.0.5

Published

CSS Benchmarking command line tool using Chrome's remote debugging protocol

Downloads

40

Readme

Topmarks

Build Status codecov Dependency Status NPM

CSS Benchmarking command line tool using Chrome's remote debugging protocol.


Installation

If you want to install Topmarks as a command line tool, just install it globally from npm:

npm install -g topmarks

To use Topmarks in a project use:

npm install --save topmarks

Preparing the Browser for Use With Topmarks

Topcoat utilizes the remote debugger protocol to send commands to the browser and receive reports. Currently the default plugins are optimized for Chrome.

To start Chrome with remote debugging enabled, it needs to be started from the command line with the --remote-debugging-port=9222 flag included (port 9222 is the default).

A helpful script is added to the package.json for starting it on a Mac with Chrome installed in the standard location. From the project directory it can be called using npm run chrome and it will execute:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=$TMPDIR/chrome-profiling --no-default-browser-check --window-size="800,600"

Options

Both the command line tool and node interfaces can use an options object.

Options should be formatted as an object with keys corresponding to the plugin slug (camel cased plugin name), and/or a default key.

The option object is flattened by the Topmarks.getOptions method and passed through to the plugin with the plugin specific options overriding any defaults.

import Topmarks from 'topmarks';

const options = {
  default: {
    url: "http://topcoat.io",
    port: 9223
  },
  somePlugin: {
    url: "http://google.com"
  }
};

const topmarks = new Topmarks(options);
console.log(topmarks.getOptions('somePlugin'));

Output:

{
  url: "http://google.com",
  port: 9223
}

If no options object is provided Topmarks will use these defaults:

{
  default: {
    port: 9222,
    url: 'http://topcoat.io'
  }
}

Usage

CLI

Topmarks can also be run from the command line (if installed globally) or as an npm script.

When installed globally, Topmarks is available from the command line as the topm command.

topm --help

Will return the list of commands and options:

  • -h, --help - output usage information.

  • -V, --version - output the version number.

  • -p, --port [port] - The debugging port for google-chrome (default: 9222).

  • -u, --url [url] - Writes results to json file (default: http://topcoat.io).

  • -o, --output [filename] - Writes results to json file as an array of result objects.

  • -a, --append-output - Appends results data to the end of an existing json file (defined in --output).

  • -q, --plugins [plugin(s)] - A list of Topmark test plugins to run (runs default plugins if not specified). Currently you have to pass an absolute path to the plugin, something I'd like to fix in the future.

    topm --plugins "[/path/to/some-plugin,/path/to/another-plugin]"
  • -t, --parameters [string of options] - A JSON string of options to be passed to plugins.

    topm --parameters "{default:{url:'http://example.com'}}"

Node

Topmarks can also be run by Node.js.

import Topmarks from 'topmarks';

const topmarks = new Topmarks({ default: { url: "http://google.com" } });
topmarks.register('topmark-loadspeed').then(() => {
  //Do something after loading plugins
  //Get access to the results provided by `topmarks.results`
}).catch(console.log);

Plugins

Default Plugins

The current default plugins included with topmarks:

Custom Plugins

If you'd like to write your own plugins to run tests on Topmarks take a look at how the default plugins are written.

Make sure to include the topmarks-plugin keyword in your package.json when publishing to npm if you want it to be included in the correct search