We have to cover five main categories in Lighthouse (here you can see how they are measured in v3, but I’m not sure if it’s 100% accurate, because the current version of Lighthouse is already 4.1).
Performance
There are 5 metrics that score in this category:
-
Time To Interactive (5)
Mesures three things: first contentful paint, event handlers are registered for most visible elements and user interactions get a response in less than 50ms. -
Speed Index (4)
Mesures how quickly the content of a page is populated. -
First Contentful Paint (3)
Measures the time from navigation to the time when the browser renders the first bit of content from the DOM. -
First CPU Idle (2)
Is a more vague version of Time To Interactive. -
First Meaningful Paint (1)
This audit identifies the time at which the user feels that the primary content of the page is visible.
What we can do for all of this metrics is basically the same: code splitting, tree shaking, compressing resources (maybe using brotli, with 85% support), caching resources, avoid unnecessary requests and avoid synchronous requests.
It shouldn’t be that difficult now that we’ll have full control on what is used and we’ll mesure only the framework without 3rd party libraries.
Progressive Web App
There are 11 checks, all of them with the same weight.
-
Contains Some Content When JS Is Not Available
This audit performs a simple check to ensure that your page isn’t blank when JS is disabled.
In these cases we could serve the SSR with local links. It would offer sufficient navigation functionality. -
Page Load Is Fast Enough On Mobile
If the time to interactive is less than 10s on a slow 4G, the audit passes. -
User Can Be Prompted To Install The Web App
Different browsers have different criteria for the banner to prompt. -
Configured For A Custom Splash Screen
This will be done in themanifest.json
file. -
Content Sized Correctly for Viewport
Checks that the width of the content on your page is equal to the width of the viewport. -
Address Bar Matches Brand Colors
The audit passes if Lighthouse finds atheme-color
meta tag in the page’s HTML and atheme_color
property inmanifest.json
. -
The
short_name
won’t be truncated on the homescreen
Accessibility
There are too many cases to cover here, I think we should just go with eslint-plugin-jsx-a11y
and then check Lighthouse to see what we are missing.
I also think most of these checks will be something that theme developers will need to take care of, and not something that we at the framework level will need to pay special attention.
Best Practices
There are 16 checks in this category, some of them as generic as Avoids front-end JavaScript libraries with known security vulnerabilities
, so again I think there is no strategy here, we should just run Lighthouse and fix them one by one.
SEO
There are 10 checks in this category.
-
Document doesn’t have a valid
hreflang
If you serve different content based on a user’s language or region, usehreflang
links to ensure that search engines serve the correct content for that language or region. -
Document Doesn’t Use Legible Font Sizes
Aim to have a font size of at least 12px on at least 60% of the text on your pages. -
Page has unsuccessful HTTP status code
Ensure that your server returns a 2XX or 3XX HTTP status code.
Ways To Integrate Lighthouse in Frontity (or in Frontity’s workflow)
I don’t know what is the better way to achieve this, but we have at our disposal Lighthouse Node CLI.
I think this could be integrated with Github + Travis (video) or maybe it could also be included as a tool in our Frontity Admin board.
This way we could show a history of audits and the developer could easily check if what he is doing is working or not. This could be just a bunch of .json
files saved in the repo, I guess, that we then render on the admin board.
There are some tools around the Node CLI that may come in handy like: webpack-lighthouse-plugin, lighthouse-gh-reporter…
There is also a video talking about the Lighthouse REST API but I think they are still in private beta, because I couldn’t find any docs about it.