This document lists the full set of changes between version 4 and version 5 that are relevant to anyone wanting to upgrade to the new version. This document groups changes into "breaking changes", "new features", and "deprecations" across both the "standard" and "attribution" builds (see build options for details).
- Removed First Input Delay (FID) support and
onFID()as deprecated in v4. FID has been replaced by INP and this removal was previously advertised in that announcement post. (#519) - Changed the browser support policy to Baseline Widely available browser support. (#525)
All of the builds in web-vitals v5 use only Baseline Widely available APIs, which means they should run without error in all browsers released in the last few years. Note that the Core Web Vitals metrics are only available in modern browsers, so legacy browser support is unnecessary for this library.
If your site needs to support legacy browsers, you can still use the web-vitals library without causing errors in those browsers by adhering to the following recommendations:
We recommend loading the web-vitals library in a separate script file from your site's main application bundle(s), either via <script type="module"> and import statements or via your bundler's code splitting feature (for example, rollup, esbuild, and webpack). This ensures that any errors encountered while loading the library do not impact other code on your site.
If you do choose to include the web-vitals library code in your main application bundle—and you also need to support very old browsers—it's critical that you configure your bundler to transpile the web-vitals code along with the rest of you application JavaScript. This is important because most bundlers do not transpile node_modules by default.
- Changed to sort the classes that appear in attribution selectors to reduce cardinality. While not a breaking change in the API, this may result in a short term difference in reports based on the selector during the change over from v4 to v5, but longer term should result in few selectors that are more easily grouped in reporting. (#518)
- Changed
LCPAttribution.elementtoLCPAttribution.targetas part of (#585) for consistency. - Removed
INPAttribution.interactionTargetElementby default. If needed this can be generated as part of support for generating custom targets in the attribution build (#585)
- Added support for generating custom targets in the attribution build (#585)
- Added extended INP attribution with extra LoAF information: longest script and buckets (#592)
There were no deprecations in v5.