Skip to content

Show HN: Single-line command to audit Accessibility score of a website

2 pointstpkahlondiscuss
On HN

First, ensure you have Lighthouse installed globally by running "npm i -g lighthouse".

Then, run the following script to audit any desired site against the accessibility test.

If the audit is successful, you will see "Accessibility score is 100." printed in the terminal. Otherwise, it will list all the errors in the terminal which the site administrator can debug and patch.

site="https://google.ca"; form_factor="--emulated-form-factor=desktop"; accessibility_score=$(lighthouse --only-categories=accessibility "$form_factor" "$site" --quiet --output=json | jq -r '.categories.accessibility.score * 100'); if [[ $accessibility_score == 100 ]]; then echo "Accessibility score is 100."; else (echo "Accessibility score is $accessibility_score." && lighthouse --only-categories=accessibility "$form_factor" "$site" --quiet --output=json | jq '.audits | to_entries[] | select(.value.score == 0) | .value.details.items') fi

NOTE:

a) You can audit the test for either "desktop" or "mobile" by setting the "--emulated-form-factor" flag to the desired value.

Comments

No comments yet.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.