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

helmut

v1.0.1

Published

Automated full page screenshots of a site at multiple viewport sizes with Puppeteer and Node.js

Downloads

52

Readme

Helmut

Helmut is a Node.js script that uses the Puppeteer API to take automated full page screenshots of a site at multiple viewport sizes.

Installation

npm install -g helmut

Please note that a version of the Chromium browser will be downloaded, so the download size could be over 300 MB.

Node.js v7.6.0 or greater is required.

Usage

The script revolves around the idea of a photo session JavaScript object that describes what to shoot and in which way.

Let's say we are developing a portfolio site, and that we want to 'portrait' a bunch of its pages to inspect how they look when displayed on a variety of browser viewport sizes.

We create a JSON file called photo-session.json in the location where the screenshots must be saved. This file has a format like this:

{
  "baseURL": "http://localhost",
  "pages": [
    "/",
    "/about",
    "/contact",
    "/portfolio/",
    "/portfolio/item1/",
    "/portfolio/item2/",
    "/portfolio/item3/",
  ],
  "viewports": [
    [320, 480],
    [375, 812],
    [768, 1024],
    [1024, 768],
    [1280, 800],
    [1440, 900],
    [1920, 1080],
    [2560, 1440]
  ]
}

After the base URL of the site, there is the list of the relative URLs of the pages to shoot, and finally the viewport sizes at which these shots have to be taken.

Having configured the shooting session, the script can be launched from the command line:

helmut

The script outputs some information to the console and starts saving the screenshots into a timestamped folder named after the session name, something like photo-session@2018-12-01T12-29-44-358Z.

The screenshots generally have the same height as the page. But if the page is shorter than the browser viewport, then they have the same height as the viewport.

Let's define another session, this time to test the home page. We create another JSON file, let's call it home.json:

{
  "pages": [
    "http://localhost/"
  ],
  "viewports": [
    [320, 480],
    [375, 812],
    [768, 1024],
    [1024, 768],
    [1280, 800],
    [1440, 900],
    [1920, 1080],
    [2560, 1440]
  ]
}

There's only one page here, so the baseURL property was omitted.

To launch the script with this configuration, just pass it the session name on the command line:

helmut home

This time the shots are stored in home@some-timestamp-here. If no session name is passed to the script, a default photo-session name is used, as in the first example.