Scanning for Website Errors with Lighthouse CLI

WordPress is preparing to finally upgrade the bundled version of jQuery. The first step was completed as of WordPress 5.5 which was to remove jQuery migrate. That bumps the minimal jQuery compatible to v1.9 which is a 7 years old release of jQuery. Still many older themes and plugins in the WordPress ecosystem may not be fully compatible.

WordPress released the plugin Enable jQuery Migrate Helper which brings back the old jQuery migrate script. It’s useful if you run into a compatibly issue with WordPress 5.5 and just need the website to work. I must rather solve compatibility related issues rather than relying on an outdated workaround fix. So I’ve been actively applying WordPress 5.5 compatibility patches for any Anchor Hosting customers that need it.

Lighthouse is amazing and collects a ton of information about a website.

Google says that Lighthouse is an open-source, automated tool for improving the quality of web pages. Running Lighthouse produces a very comprehensive report which can be a bit overwhelming. Luckily the output can be limited by targeting specific audits. Considering Lighthouse simply uses a real Google Chrome browser to collect information, I thought it might be the perfect tool to use for helping me identifying WordPress 5.5 compatibility issues.

Bulk scanning WordPress websites with Lighthouse CLI.

Lighthouse has a CLI which even supports headless Chrome and JSON output. That means you can truly automate anything through Lighthouse, even from a Linux server which only has terminal access. This one liner will scan a site with lighthouse cli and return any Chrome console errors.

lighthouse https://example-site.tld --only-audits=errors-in-console --chrome-flags="--headless" --output=json --quiet

In order to find and fix the most critical WordPress 5.5 compatibility issues, I built an error scanner with Lighthouse CLI based on the above one liner. With it I scanned each customer’s homepage for errors then put them into a single place where I could review, fix and rescan. It worked out brilliantly well and in fact it uncovered a bunch of other minor issues. If you’re an Anchor Hosting customer you can see it for your own sites here: anchor.host/account/health.

New Health section bundled into my toolkit

Out of 1200+ sites scanned around 350 sites had at least 1 error notice.

Most of these errors weren’t related to WordPress 5.5 however it was really easy to search though and pull out which ones were. This isn’t going to catch every Javascript-related issue however it’s a great start. I could see value in expanded it to scan other pages or even better, scanning the WordPress backend. I suspect getting through the WordPress login would get tricky for bulk sites. A problem to tackle for another day.