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

shopback-seo-quiz

v1.1.0

Published

A Node.js package to let user scan a HTML content and show all of the SEO defects

Readme

const sb = require('shopback-seo-quiz');

sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
    // add first custom SEO rule
    var new_rule_1 = new sb.rules.rule_tag_exceed_max(["img"], 1);
    sb.add_seo_rule(new_rule_1);

    // add second custom SEO rule
    var new_rule_2 = new sb.rules.rule_no_attr_value(["head", "meta"], "name", "robots");
    sb.add_seo_rule(new_rule_2);

    // rule indices less than 8 are pre-defined rules
    // skip pre-defined SEO rule 5
    sb.skip_seo_rule(5, true);

    // skip first custom SEO rule
    sb.skip_seo_rule(new_rule_1, true);

    // get test report and show on console
    sb.report(sb.io_types.CONSOLE);
}).catch((err) => {
    console.error(err);
});

Requirements

Node.js 8.0 or greater

Installation

npm install shopback-seo-quiz

Predefined Rules

  1. Detect if there are any <img /> tags without alt attribute
  2. Detect if there are any <a /> tags without rel attribute
  3. Detect if there is any header that doesn’t have <title> tag
  4. Detect if there is any header that doesn’t have <meta name="descriptions" … /> tag
  5. Detect if there is any header that doesn’t have <meta name="keywords" … /> tag
  6. Detect if there are more than 15 <strong> tag in HTML
  7. Detect if a HTML have more than 1 <h1> tag

API

Customize pre-defined rule arguments

Use third argument of load_html method to customize pre-defined rule arguments. Two options can be set by user: tag_strong_max and tag_h1_max.

const sb = require('shopback-seo-quiz');

var options = {"tag_strong_max": 8, "tag_h1_max": 2};
sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`, options).then(() => {
  ...
}).catch((err) => {
  ...
});

Rules

There are 4 different types of rule can be add to SEO rules: rule_no_attr_count, rule_no_child_tag, rule_no_attr_value and rule_tag_exceed_max. Use add_seo_rule method to add new SEO rule.

const sb = require('shopback-seo-quiz');
const rules = sb.rules;

// create rules
var pre_def_rule_1 = new rules.rule_no_attr_count(["img"], "alt");
var pre_def_rule_3 = new rules.rule_no_child_tag(["head", "title"]);
var pre_def_rule_4 = new rules.rule_no_attr_value(["head", "meta"], "name", "descriptions");
var pre_def_rule_6 = new rules.rule_tag_exceed_max(["strong"], 15);

// Add rules
sb.add_seo_rule(pre_def_rule_1);
sb.add_seo_rule(pre_def_rule_3);
sb.add_seo_rule(pre_def_rule_4);
sb.add_seo_rule(pre_def_rule_6);
sb.add_seo_rule(new rules.rule_no_attr_count(["a"], "rel"));

Skip rules

Use skip_seo_rule method to enable/disable skip flag of rules. The first parameter can be a rule object or rule index. Skip the rule if second parameter is set to true. (rule indices less than 8 are pre-defined rules)

const sb = require('shopback-seo-quiz');

sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
    // add first custom SEO rule
    var new_rule_1 = new sb.rules.rule_tag_exceed_max(["img"], 1);
    sb.add_seo_rule(new_rule_1);

    // skip fifth pre-defined SEO rule
    sb.skip_seo_rule(5, true);

    // skip first custom SEO rule
    sb.skip_seo_rule(new_rule_1, true);

    // get test report and show on console
    sb.report(sb.io_types.CONSOLE);
}).catch((err) => {
    ...
});

Input

There are 2 input types: sb.io_types.FILE and sb.io_types.STREAM. Use load_html method to load input HTML.

const sb = require('shopback-seo-quiz');
const fs = require('fs');

// file input
sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
  ...
}).catch((err) => {
  ...
});

// readable stream input
sb.load_html(sb.io_types.STREAM`, fs.createReadStream(`${__dirname}/test.html`)).then(() => {
  ...
}).catch((err) => {
  ...
});

Output

There are 3 output types: sb.io_types.FILE, sb.io_types.STREAM and sb.io_types.CONSOLE. Use report method to get SEO verification report.

const sb = require('shopback-seo-quiz');
const fs = require('fs');

// console output
sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
  ...
  sb.report(sb.io_types.CONSOLE);
}).catch((err) => {
  ...
});

// file output
sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
  ...
  sb.report(sb.io_types.FILE, `${__dirname}/test.log`);
}).catch((err) => {
  ...
});

// writable stream output
sb.load_html(sb.io_types.FILE, `${__dirname}/test.html`).then(() => {
  ...
  sb.report(sb.io_types.STREAM, fs.createWriteStream(`${__dirname}/test.log`));
}).catch((err) => {
  ...
});

Test package

Run npm test in the shopback-seo-quiz module.