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

compat-tester

v0.2.10

Published

Diagnose the compatibility of a site regarding browsers and environments

Downloads

34

Readme

compat-tester

compat-tester is a static tool analysis that, provided a "browser scope", scans HTML, CSS and JS files and outputs a compatibility report for features that might not be available for such a scope (e.g. if my scope contains IE8 and my style.css stylesheet contains CSS Grid properties).

compat-tester's approach is pretty naive and currently doesn't detect any progressive enhancement, polyfills, etc. that could improve actual compatibility.

This tool is heavily built upon:

This project must be considered as alpha-stage.

Install

npm install compat-tester

Usage

As an command line tool

compat-tester # Scans index.html as root file and uses scope.json as defaults
compat-tester mySite.html myScope.json
compat-tester https://developer.mozilla.org/en-US/ myScope.json # Scans the remote web page
compat-tester -html myPage.html myScope.json  # Only scans the HTML of myPage.html
compat-tester -css myStyle.css myScope.json   # Only scans the CSS of myStyle.css
compat-tester -js myScript.js myScope.json    # !Not implemented yet! Only scans myScript.js

As a module

const compatTester = require("compat-tester");
const options = {"contrib": "all"} // "all"|"true"|"null"
let report = compatTester.cssStringAnalyzer(string, browserScope, callback[, options ]);
let report = compatTester.cssFileAnalyzer(filePath, browserScope, callback[, options ]);
let report = compatTester.htmlStringAnalyzer(string, browserScope, callback[, options ]);
let report = compatTester.htmlFileAnalyzer(filePath, browserScope, callback[, options ]);
let report = compatTester.jsStringAnalyzer(string, browserScope, callback[, options ]); // Not implemented yet
let report = compatTester.jsFileAnalyzer(filePath, browserScope, callback[, options ]); // Not implemented yet

Browser-scope file

The scope.json file is simply a JSON file where the keys are the identifiers of the browsers you want/need to support, following mdn-browser-compat's syntax and where the values are the minimum version you want/need to support. For instance with the following scope.json

{
    "ie":"8",
    "firefox":"34"
}

compat-tester will report any detected feature that isn't available before Internet Explorer 8 and Firefox 34.

Examples

Using an scope with IE "1" (not a typo ;)) and Firefox "8", the report might look like:

HTML Report:
        firefox incompatible - @index.html#L21 - <link> - attrcrossorigin - minVer: 18
        firefox incompatible - @index.html#L21 - <link> - attrintegrity not implemented
        firefox incompatible - @index.html#L99 - <link> - attrcrossorigin - minVer: 18
        firefox incompatible - @index.html#L186 - <details> - minVer: 49
        ie incompatible - @index.html#L21 - <link> - attrcrossorigin not implemented
        ie incompatible - @index.html#L21 - <link> - attrintegrity not implemented
        ie incompatible - @index.html#L99 - <link> - attrcrossorigin not implemented
        ie incompatible - @index.html#L117 - <header> - minVer: 9
        ie incompatible - @index.html#L186 - <details> not implemented
CSS Report:
        firefox incompatible - @test_files/style.css#L191 - Property: animation - minVer: 16
        firefox incompatible - @test_files/style.css#L477 - Property: word-wrap - minVer: 49
        firefox incompatible - @test_files/style.css#L485 - Property: font-variant-ligatures - minVer: 34
        firefox incompatible - @test_files/style.css#L489 - Property: word-wrap - minVer: 49
        firefox incompatible - @test_files/style.css#L491 - Property: word-break - minVer: 15
        firefox incompatible - @test_files/style.css#L522 - Property: box-sizing - minVer: 29
        firefox incompatible - @test_files/style.css#L686 - Property: box-sizing - minVer: 29
        firefox incompatible - @test_files/style.css#L941 - Property: transform - minVer: 16
        ie incompatible - @test_files/style.css#L49 - Property: background-color - minVer: 4
        ie incompatible - @test_files/style.css#L54 - Property: background-color - minVer: 4
        ie incompatible - @test_files/style.css#L58 - Property: content - minVer: 8
        ie incompatible - @test_files/style.css#L62 - Property: font-weight - minVer: 3
        …

Limitations - Wishlist

The following features are currently missing :'(

CSS

(current feature set: properties, @-rules)

  • Selectors

JavaScript

(current feature set: nothing)

  • Parsing JS and dealing with primary features like statements, operators

Misc.

  • Resolving a tree of resources (e.g. fetch internal HTML pages, CSS with @import…)
  • Adding comments to locally disable warnings
  • An interactive CLI to easily create a scope.json file (something like "compat-tester --init")
  • Tests

Integration

  • Addon for VSCode
  • Addon for SublimeText

Notes

This project is one of my first "real" JavaScript project, feel free to add issues if you see any minor/major/confusing/horrendous stuff.