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

gulp-sitespeedio

v2.0.0

Published

Analyze the web performance of your site using Gulp

Downloads

226

Readme

gulp-sitespeedio

Test your website using sitespeed.io

gulp-sitespeedio is a gulp.js task for testing your site against web performance best practice rules, fetch timings from a browser, test and enforce performance budgets, send performance metrics to Graphite using sitespeed.io.

Check out the documentation to get a full overview of what you can do and test using sitespeed.io.

Getting Started

If you haven't used gulp before, be sure to check out the Getting Started guide, as it explains how to create a gulpfile.js as well as install and use gulp plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install gulp-sitespeedio --save-dev

Once the plugin has been installed, it may be enabled inside your gulpfile with this line of JavaScript:

var sitespeedio = require('gulp-sitespeedio');

The sitespeedio task

Required configuration properties

To start testing pages, you must configure either a start URL for your crawl (yep sitespeed.io will crawl your site for a configurable depth) or an array of specific URL's that you want to test.

Crawl the site with depth 1.

{
  urls: ['http://localhost/'],
}

Testing specific URLs

{
  urls: ['https://www.sitespeed.io', 'https://www.sitespeed.io/faq/']
}

With these configuration properties set, you can add sitespeedio to your default tasks list. That'll look something like this:

gulp.task('default', ['jshint', 'sitespeedio']);

If you run it with custom options you need to run like this:

gulp.task('default', function (done) {
  sitespeedio({
    urls: ["http://localhost:3000/"],
  })(done)
});

With this in place, gulp-sitespeedio will now collect performance metrics for your site.

The result files

The result files will automatically be stored in a temporary directory. If you want to change that, use the resultBaseDir property, like this:


{
  url: 'https://www.sitespeed.io',
  outputFolder: '/my/new/dir/'
}

Use cases

Fetch timings, sending performance metrics to Graphite and performance budgets.

Fetching timing metrics

You can choose to collect Navigation Timing and User Timing metrics using real browser. You can choose by using Firefox or Chrome. And you can configure the connection speed (more info by choosing between mobile3g, mobile3gfast, cable and native. And choose how many times you want to test each URL (default is 3).

You surely want to combine it with running Xvfb to avoid opening the browser.

{
  urls: ['https://www.sitespeed.io', 'https://www.sitespeed.io/faq/'],
  browsertime: {
    browser: 'firefox'
    connectivity: 'cable',
    iterations: 5,
  }
}

Performance Budget

Test your site against a performance budget. You can test your site against almost all data collected by sitespeed.io.

Checkout the example Gruntfile and budget looks something like this:

budget: {
  "browsertime.pageSummary": [{
    "metric": "statistics.timings.firstPaint.median",
    "max": 1000
  }, {
    "metric": "statistics.visualMetrics.FirstVisualChange.median",
    "max": 1000
  }],
  "coach.pageSummary": [{
    "metric": "advice.performance.score",
    "min": 75
  }, {
    "metric": "advice.info.domElements",
    "max": 200
  }, {
    "metric": "advice.info.domDepth.max",
    "max": 10
  }, {
    "metric": "advice.info.iframes",
    "max": 0
  }, {
    "metric": "advice.info.pageCookies.max",
    "max": 5
  }],
  "pagexray.pageSummary": [{
    "metric": "transferSize",
    "max": 100000
  }, {
    "metric": "requests",
    "max": 20
  }, {
    "metric": "missingCompression",
    "max": 0
  }, {
    "metric": "contentTypes.css.requests",
    "max": 1
  }, {
    "metric": "contentTypes.image.transferSize",
    "max": 100000
  }, {
    "metric": "documentRedirects",
    "max": 0
  }]
}

If you want to include/exclude tests in the output, you can switch that by a gulp config like:


{
  urls: ['https://www.sitespeed.io', 'https://www.sitespeed.io/faq/'],
  showFailedOnly: true // or false
}

Can't find the configuration

sitespeed.io is highly configurable. The gulp-sitespeedio plugin will pass every option to sitespeed, you can see each and every configuration here. Each option needs to be called with full name (meaning the same as using -- for the cli. Say for example that don't need the screenshot for each. Using the cli, you add the flag --browsertime.screenshot false

Doing the same with the gulp plugin:

{
  url: 'https://www.sitespeed.io',
  browsertime: {
        screenshot: false
    }
}