Skip to content

Latest commit

 

History

History
39 lines (22 loc) · 3.58 KB

File metadata and controls

39 lines (22 loc) · 3.58 KB

Upgrading to v5

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).

❌ Breaking changes

Standard build

General

More details on the Baseline Widely available change:

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.

Attribution build

INPAttribution, LCPAttribution, and CLSAttribution

  • 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.element to LCPAttribution.target as part of (#585) for consistency.
  • Removed INPAttribution.interactionTargetElement by default. If needed this can be generated as part of support for generating custom targets in the attribution build (#585)

🚀 New features

  • Added support for generating custom targets in the attribution build (#585)
  • Added extended INP attribution with extra LoAF information: longest script and buckets (#592)

⚠️ Deprecations

There were no deprecations in v5.