{
  "manifest": {
    "name": "web-vitals",
    "version": "2.1.4",
    "description": "Easily measure performance metrics in JavaScript",
    "main": "dist/web-vitals.umd.js",
    "module": "dist/web-vitals.js",
    "typings": "dist/modules/index.d.ts",
    "files": [
      "base.js",
      "base.d.ts",
      "dist",
      "src"
    ],
    "scripts": {
      "build": "run-s clean build:ts build:js",
      "build:ts": "tsc -b",
      "build:js": "rollup -c",
      "clean": "rm -rf dist tsconfig.tsbuildinfo",
      "dev": "run-p watch test:server",
      "lint": "eslint \"*.js\" \"src/**/*.ts\" \"test/**/*.js\"",
      "lint:fix": "eslint --fix \"*.js\" \"src/**/*.ts\" \"test/**/*.js\"",
      "postversion": "git push --follow-tags",
      "release:major": "npm version major -m 'Release v%s' && npm publish",
      "release:minor": "npm version minor -m 'Release v%s' && npm publish",
      "release:patch": "npm version patch -m 'Release v%s' && npm publish",
      "test": "npm-run-all build -p -r test:*",
      "test:e2e": "wdio wdio.conf.js",
      "test:server": "node test/server.js",
      "start": "run-s build:ts test:server watch",
      "watch": "run-p watch:*",
      "watch:ts": "tsc -b -w",
      "watch:js": "rollup -c -w",
      "version": "run-s build",
      "prepare": "husky install"
    },
    "keywords": [
      "crux",
      "performance",
      "metrics",
      "CLS",
      "FCP",
      "FID",
      "LCP",
      "TTFB"
    ],
    "author": {
      "name": "Philip Walton",
      "email": "philip@philipwalton.com",
      "url": "http://philipwalton.com"
    },
    "license": "Apache-2.0",
    "repository": {
      "type": "git",
      "url": "https://github.com/GoogleChrome/web-vitals.git"
    },
    "bugs": {
      "url": "https://github.com/GoogleChrome/web-vitals/issues"
    },
    "husky": {
      "hooks": {
        "pre-commit": "npm run lint"
      }
    },
    "devDependencies": {
      "@babel/core": "^7.16.10",
      "@babel/preset-env": "^7.16.11",
      "@rollup/plugin-replace": "^3.0.1",
      "@typescript-eslint/eslint-plugin": "^5.10.0",
      "@typescript-eslint/parser": "^5.10.0",
      "@wdio/cli": "^7.16.13",
      "@wdio/local-runner": "^7.16.13",
      "@wdio/mocha-framework": "^7.16.13",
      "@wdio/selenium-standalone-service": "^7.16.13",
      "@wdio/spec-reporter": "^7.16.13",
      "body-parser": "^1.19.1",
      "chromedriver": "^97.0.0",
      "eslint": "^8.7.0",
      "eslint-config-google": "^0.14.0",
      "express": "^4.17.2",
      "fs-extra": "^10.0.0",
      "husky": "^7.0.4",
      "npm-run-all": "^4.1.5",
      "nunjucks": "^3.2.3",
      "rollup": "^2.64.0",
      "rollup-plugin-babel": "^4.4.0",
      "rollup-plugin-terser": "^7.0.2",
      "typescript": "^4.5.5",
      "wdio-chromedriver-service": "^7.2.6"
    },
    "_registry": "npm",
    "_loc": "/homez.1033/heliovt/.cache/yarn/v6/npm-web-vitals-2.1.4-76563175a475a5e835264d373704f9dde718290c-integrity/node_modules/web-vitals/package.json",
    "readmeFilename": "README.md",
    "readme": "# `web-vitals`\n\n- [Overview](#overview)\n- [Install and load the library](#installation)\n  - [From npm](#import-web-vitals-from-npm)\n  - [From a CDN](#load-web-vitals-from-a-cdn)\n- [Usage](#usage)\n  - [Basic usage](#basic-usage)\n  - [Report the value on every change](#report-the-value-on-every-change)\n  - [Report only the delta of changes](#report-only-the-delta-of-changes)\n  - [Send the results to an analytics endpoint](#send-the-results-to-an-analytics-endpoint)\n  - [Send the results to Google Analytics](#send-the-results-to-google-analytics)\n  - [Send the results to Google Tag Manager](#send-the-results-to-google-tag-manager)\n  - [Batch multiple reports together](#batch-multiple-reports-together)\n- [Bundle versions](#bundle-versions)\n  - [Which bundle is right for you?](#which-bundle-is-right-for-you)\n  - [How the polyfill works](#how-the-polyfill-works)\n- [API](#api)\n  - [Types](#types)\n  - [Functions](#functions)\n- [Browser Support](#browser-support)\n- [Limitations](#limitations)\n- [Development](#development)\n- [Integrations](#integrations)\n- [License](#license)\n\n## Overview\n\nThe `web-vitals` library is a tiny (~1K), modular library for measuring all the [Web Vitals](https://web.dev/vitals/) metrics on real users, in a way that accurately matches how they're measured by Chrome and reported to other Google tools (e.g. [Chrome User Experience Report](https://developers.google.com/web/tools/chrome-user-experience-report), [Page Speed Insights](https://developers.google.com/speed/pagespeed/insights/), [Search Console's Speed Report](https://webmasters.googleblog.com/2019/11/search-console-speed-report.html)).\n\nThe library supports all of the [Core Web Vitals](https://web.dev/vitals/#core-web-vitals) as well as all of the [other Web Vitals](https://web.dev/vitals/#other-web-vitals) that can be measured [in the field](https://web.dev/user-centric-performance-metrics/#how-metrics-are-measured):\n\n### Core Web Vitals\n\n- [Cumulative Layout Shift (CLS)](https://web.dev/cls/)\n- [First Input Delay (FID)](https://web.dev/fid/)\n- [Largest Contentful Paint (LCP)](https://web.dev/lcp/)\n\n### Other Web Vitals\n\n- [First Contentful Paint (FCP)](https://web.dev/fcp/)\n- [Time to First Byte (TTFB)](https://web.dev/ttfb/)\n\n<a name=\"installation\"><a>\n<a name=\"load-the-library\"><a>\n\n## Install and load the library\n\n<a name=\"import-web-vitals-from-npm\"><a>\n\n### From npm\n\nYou can install this library from npm by running:\n\n```sh\nnpm install web-vitals\n```\n\n_**Note:** If you're not using npm, you can still load `web-vitals` via `<script>` tags from a CDN like [unpkg.com](https://unpkg.com). See the [load `web-vitals` from a CDN](#load-web-vitals-from-a-cdn) usage example below for details._\n\nThere are two different versions of the `web-vitals` library (the \"standard\" version and the \"base+polyfill\" version), and how you load the library depends on which version you want to use.\n\nFor details on the difference between the two versions, see <a href=\"#which-bundle-is-right-for-you\">which bundle is right for you</a>.\n\n**1. The \"standard\" version**\n\nTo load the \"standard\" version, import modules from the `web-vitals` package in your application code (as you would with any npm package and node-based build tool):\n\n```js\nimport {getLCP, getFID, getCLS} from 'web-vitals';\n\ngetCLS(console.log);\ngetFID(console.log);\ngetLCP(console.log);\n```\n\n<a name=\"how-to-use-the-polyfill\"><a>\n\n**2. The \"base+polyfill\" version**\n\nLoading the \"base+polyfill\" version is a two-step process:\n\nFirst, in your application code, import the \"base\" build rather than the \"standard\" build. To do this, change any `import` statements that reference `web-vitals` to `web-vitals/base`:\n\n```diff\n- import {getLCP, getFID, getCLS} from 'web-vitals';\n+ import {getLCP, getFID, getCLS} from 'web-vitals/base';\n```\n\nThen, inline the code from `dist/polyfill.js` into the `<head>` of your pages. This step is important since the \"base\" build will error if the polyfill code has not been added.\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <script>\n      // Inline code from `dist/polyfill.js` here\n    </script>\n  </head>\n  <body>\n    ...\n  </body>\n</html>\n```\n\nNote that the code _must_ go in the `<head>` of your pages in order to work. See [how the polyfill works](#how-the-polyfill-works) for more details.\n\n_**Tip:** while it's certainly possible to inline the code in `dist/polyfill.js` by copy and pasting it directly into your templates, it's better to automate this process in a build step—otherwise you risk the \"base\" and the \"polyfill\" scripts getting out of sync when new versions are released._\n\n<a name=\"load-web-vitals-from-a-cdn\"><a>\n\n### From a CDN\n\nThe recommended way to use the `web-vitals` package is to install it from npm and integrate it into your build process. However, if you're not using npm, it's still possible to use `web-vitals` by requesting it from a CDN that serves npm package files.\n\nThe following examples show how to load `web-vitals` from [unpkg.com](https://unpkg.com), whether your targeting just Chromium-based browsers (using the \"standard\" version) or additional browsers (using the \"base+polyfill\" version):\n\n**Load the \"standard\" version** _(using a module script)_\n\n```html\n<!-- Append the `?module` param to load the module version of `web-vitals` -->\n<script type=\"module\">\n  import {getCLS, getFID, getLCP} from 'https://unpkg.com/web-vitals?module';\n\n  getCLS(console.log);\n  getFID(console.log);\n  getLCP(console.log);\n</script>\n```\n\n**Load the \"standard\" version** _(using a classic script)_\n\n```html\n<script>\n(function() {\n  var script = document.createElement('script');\n  script.src = 'https://unpkg.com/web-vitals/dist/web-vitals.iife.js';\n  script.onload = function() {\n    // When loading `web-vitals` using a classic script, all the public\n    // methods can be found on the `webVitals` global namespace.\n    webVitals.getCLS(console.log);\n    webVitals.getFID(console.log);\n    webVitals.getLCP(console.log);\n  }\n  document.head.appendChild(script);\n}())\n</script>\n```\n\n**Load the \"base+polyfill\" version** _(using a classic script)_\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <script>\n      // Inline code from `https://unpkg.com/web-vitals/dist/polyfill.js` here.\n    </script>\n  </head>\n  <body>\n    ...\n    <!-- Load the UMD version of the \"base\" bundle. -->\n    <script>\n    (function() {\n      var script = document.createElement('script');\n      script.src = 'https://unpkg.com/web-vitals/dist/web-vitals.base.iife.js';\n      script.onload = function() {\n        // When loading `web-vitals` using a classic script, all the public\n        // methods can be found on the `webVitals` global namespace.\n        webVitals.getCLS(console.log);\n        webVitals.getFID(console.log);\n        webVitals.getLCP(console.log);\n      }\n      document.head.appendChild(script);\n    }())\n    </script>\n  </body>\n</html>\n```\n\n## Usage\n\n### Basic usage\n\nEach of the Web Vitals metrics is exposed as a single function that takes an `onReport` callback. This callback will be called any time the metric value is available and ready to be reported.\n\nThe following example measures each of the Core Web Vitals metrics and logs the result to the console once its value is ready to report.\n\n_(The examples below import the \"standard\" version, but they will work with the polyfill version as well.)_\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\ngetCLS(console.log);\ngetFID(console.log);\ngetLCP(console.log);\n```\n\nNote that some of these metrics will not report until the user has interacted with the page, switched tabs, or the page starts to unload. If you don't see the values logged to the console immediately, try reloading the page (with [preserve log](https://developers.google.com/web/tools/chrome-devtools/console/reference#persist) enabled) or switching tabs and then switching back.\n\nAlso, in some cases a metric callback may never be called:\n\n- FID is not reported if the user never interacts with the page.\n- FCP, FID, and LCP are not reported if the page was loaded in the background.\n\nIn other cases, a metric callback may be called more than once:\n\n- CLS should be reported any time the [page's `visibilityState` changes to hidden](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#advice-hidden).\n- CLS, FCP, FID, and LCP are reported again after a page is restored from the [back/forward cache](https://web.dev/bfcache/).\n\n_**Warning:** do not call any of the Web Vitals functions (e.g. `getCLS()`, `getFID()`, `getLCP()`) more than once per page load. Each of these functions creates a `PerformanceObserver` instance and registers event listeners for the lifetime of the page. While the overhead of calling these functions once is negligible, calling them repeatedly on the same page may eventually result in a memory leak._\n\n### Report the value on every change\n\nIn most cases, you only want `onReport` to be called when the metric is ready to be reported. However, it is possible to report every change (e.g. each layout shift as it happens) by setting the optional, second argument (`reportAllChanges`) to `true`.\n\nThis can be useful when debugging, but in general using `reportAllChanges` is not needed (or recommended).\n\n```js\nimport {getCLS} from 'web-vitals';\n\n// Logs CLS as the value changes.\ngetCLS(console.log, true);\n```\n\n### Report only the delta of changes\n\nSome analytics providers allow you to update the value of a metric, even after you've already sent it to their servers (overwriting the previously-sent value with the same `id`).\n\nOther analytics providers, however, do not allow this, so instead of reporting the new value, you need to report only the delta (the difference between the current value and the last-reported value). You can then compute the total value by summing all metric deltas sent with the same ID.\n\nThe following example shows how to use the `id` and `delta` properties:\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nfunction logDelta({name, id, delta}) {\n  console.log(`${name} matching ID ${id} changed by ${delta}`);\n}\n\ngetCLS(logDelta);\ngetFID(logDelta);\ngetLCP(logDelta);\n```\n\n_**Note:** the first time the `onReport` function is called, its `value` and `delta` properties will be the same._\n\nIn addition to using the `id` field to group multiple deltas for the same metric, it can also be used to differentiate different metrics reported on the same page. For example, after a back/forward cache restore, a new metric object is created with a new `id` (since back/forward cache restores are considered separate page visits).\n\n### Send the results to an analytics endpoint\n\nThe following example measures each of the Core Web Vitals metrics and reports them to a hypothetical `/analytics` endpoint, as soon as each is ready to be sent.\n\nThe `sendToAnalytics()` function uses the [`navigator.sendBeacon()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) method (if available), but falls back to the [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API when not.\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nfunction sendToAnalytics(metric) {\n  // Replace with whatever serialization method you prefer.\n  // Note: JSON.stringify will likely include more data than you need.\n  const body = JSON.stringify(metric);\n\n  // Use `navigator.sendBeacon()` if available, falling back to `fetch()`.\n  (navigator.sendBeacon && navigator.sendBeacon('/analytics', body)) ||\n      fetch('/analytics', {body, method: 'POST', keepalive: true});\n}\n\ngetCLS(sendToAnalytics);\ngetFID(sendToAnalytics);\ngetLCP(sendToAnalytics);\n```\n\n### Send the results to Google Analytics\n\nGoogle Analytics does not support reporting metric distributions in any of its built-in reports; however, if you set a unique dimension value (in this case, the metric `id`, as shown in the examples below) on every metric instance that you send to Google Analytics, you can create a report yourself using the [Google Analytics Reporting API](https://developers.google.com/analytics/devguides/reporting) and any data visualization library you choose.\n\nAs an example of this, the [Web Vitals Report](https://github.com/GoogleChromeLabs/web-vitals-report) is a free and open-source tool you can use to create visualizations of the Web Vitals data that you've sent to Google Analytics.\n\n[![web-vitals-report](https://user-images.githubusercontent.com/326742/101584324-3f9a0900-3992-11eb-8f2d-182f302fb67b.png)](https://github.com/GoogleChromeLabs/web-vitals-report)\n\nIn order to use the [Web Vitals Report](https://github.com/GoogleChromeLabs/web-vitals-report) (or build your own custom reports using the API) you need to send your data to Google Analytics following one of the examples outlined below:\n\n#### Using `analytics.js`\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nfunction sendToGoogleAnalytics({name, delta, id}) {\n  // Assumes the global `ga()` function exists, see:\n  // https://developers.google.com/analytics/devguides/collection/analyticsjs\n  ga('send', 'event', {\n    eventCategory: 'Web Vitals',\n    eventAction: name,\n    // The `id` value will be unique to the current page load. When sending\n    // multiple values from the same page (e.g. for CLS), Google Analytics can\n    // compute a total by grouping on this ID (note: requires `eventLabel` to\n    // be a dimension in your report).\n    eventLabel: id,\n    // Google Analytics metrics must be integers, so the value is rounded.\n    // For CLS the value is first multiplied by 1000 for greater precision\n    // (note: increase the multiplier for greater precision if needed).\n    eventValue: Math.round(name === 'CLS' ? delta * 1000 : delta),\n    // Use a non-interaction event to avoid affecting bounce rate.\n    nonInteraction: true,\n    // Use `sendBeacon()` if the browser supports it.\n    transport: 'beacon',\n\n    // OPTIONAL: any additional params or debug info here.\n    // See: https://web.dev/debug-web-vitals-in-the-field/\n    // dimension1: '...',\n    // dimension2: '...',\n    // ...\n  });\n}\n\ngetCLS(sendToGoogleAnalytics);\ngetFID(sendToGoogleAnalytics);\ngetLCP(sendToGoogleAnalytics);\n```\n\n#### Using `gtag.js` (Universal Analytics)\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nfunction sendToGoogleAnalytics({name, delta, id}) {\n  // Assumes the global `gtag()` function exists, see:\n  // https://developers.google.com/analytics/devguides/collection/gtagjs\n  gtag('event', name, {\n    event_category: 'Web Vitals',\n    // The `id` value will be unique to the current page load. When sending\n    // multiple values from the same page (e.g. for CLS), Google Analytics can\n    // compute a total by grouping on this ID (note: requires `eventLabel` to\n    // be a dimension in your report).\n    event_label: id,\n    // Google Analytics metrics must be integers, so the value is rounded.\n    // For CLS the value is first multiplied by 1000 for greater precision\n    // (note: increase the multiplier for greater precision if needed).\n    value: Math.round(name === 'CLS' ? delta * 1000 : delta),\n    // Use a non-interaction event to avoid affecting bounce rate.\n    non_interaction: true,\n\n    // OPTIONAL: any additional params or debug info here.\n    // See: https://web.dev/debug-web-vitals-in-the-field/\n    // metric_rating: 'good' | 'ni' | 'poor',\n    // debug_info: '...',\n    // ...\n  });\n}\n\ngetCLS(sendToGoogleAnalytics);\ngetFID(sendToGoogleAnalytics);\ngetLCP(sendToGoogleAnalytics);\n```\n\n#### Using `gtag.js` (Google Analytics 4)\n\n[Google Analytics 4](https://support.google.com/analytics/answer/10089681) introduces a new Event model allowing custom parameters instead of a fixed category, action, and label. It also supports non-integer values, making it easier to measure Web Vitals metrics compared to previous versions.\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nfunction sendToGoogleAnalytics({name, delta, value, id}) {\n  // Assumes the global `gtag()` function exists, see:\n  // https://developers.google.com/analytics/devguides/collection/ga4\n  gtag('event', name, {\n    // Built-in params:\n    value: delta, // Use `delta` so the value can be summed.\n    // Custom params:\n    metric_id: id, // Needed to aggregate events.\n    metric_value: value, // Optional.\n    metric_delta: delta, // Optional.\n\n    // OPTIONAL: any additional params or debug info here.\n    // See: https://web.dev/debug-web-vitals-in-the-field/\n    // metric_rating: 'good' | 'ni' | 'poor',\n    // debug_info: '...',\n    // ...\n  });\n}\n\ngetCLS(sendToGoogleAnalytics);\ngetFID(sendToGoogleAnalytics);\ngetLCP(sendToGoogleAnalytics);\n```\n\n### Send the results to Google Tag Manager\n\nThe recommended way to measure Web Vitals metrics with Google Tag Manager is using the [Core Web Vitals](https://www.simoahava.com/custom-templates/core-web-vitals/) custom template tag created and maintained by [Simo Ahava](https://www.simoahava.com/).\n\nFor full installation and usage instructions, see Simo's post: [Track Core Web Vitals in GA4 with Google Tag Manager](https://www.simoahava.com/analytics/track-core-web-vitals-in-ga4-with-google-tag-manager/).\n\n### Batch multiple reports together\n\nRather than reporting each individual Web Vitals metric separately, you can minimize your network usage by batching multiple metric reports together in a single network request.\n\nHowever, since not all Web Vitals metrics become available at the same time, and since not all metrics are reported on every page, you cannot simply defer reporting until all metrics are available.\n\nInstead, you should keep a queue of all metrics that were reported and flush the queue whenever the page is backgrounded or unloaded:\n\n```js\nimport {getCLS, getFID, getLCP} from 'web-vitals';\n\nconst queue = new Set();\nfunction addToQueue(metric) {\n  queue.add(metric);\n}\n\nfunction flushQueue() {\n  if (queue.size > 0) {\n    // Replace with whatever serialization method you prefer.\n    // Note: JSON.stringify will likely include more data than you need.\n    const body = JSON.stringify([...queue]);\n\n    // Use `navigator.sendBeacon()` if available, falling back to `fetch()`.\n    (navigator.sendBeacon && navigator.sendBeacon('/analytics', body)) ||\n          fetch('/analytics', {body, method: 'POST', keepalive: true});\n\n    queue.clear();\n  }\n}\n\ngetCLS(addToQueue);\ngetFID(addToQueue);\ngetLCP(addToQueue);\n\n// Report all available metrics whenever the page is backgrounded or unloaded.\naddEventListener('visibilitychange', () => {\n  if (document.visibilityState === 'hidden') {\n    flushQueue();\n  }\n});\n\n// NOTE: Safari does not reliably fire the `visibilitychange` event when the\n// page is being unloaded. If Safari support is needed, you should also flush\n// the queue in the `pagehide` event.\naddEventListener('pagehide', flushQueue);\n```\n\n_**Note:** see [the Page Lifecycle guide](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#legacy-lifecycle-apis-to-avoid) for an explanation of why `visibilitychange` and `pagehide` are recommended over events like `beforeunload` and `unload`._\n\n## Bundle versions\n\nThe `web-vitals` package includes builds for both the \"standard\" and \"base+polyfill\" versions, as well as different formats of each to allow developers to choose the format that best meets their needs or integrates with their architecture.\n\nThe following table lists all the bundles distributed with the `web-vitals` package on npm.\n\n<table>\n  <tr>\n    <td width=\"35%\">\n      <strong>Filename</strong> <em>(all within <code>dist/*</code>)</em>\n    </td>\n    <td><strong>Export</strong></td>\n    <td><strong>Description</strong></td>\n  </tr>\n  <tr>\n    <td><code>web-vitals.js</code></td>\n    <td><code>pkg.module</code></td>\n    <td>\n      <p>An ES module bundle of all metric functions, without any extra polyfills to expand browser support.</p>\n      This is the \"standard\" version and is the simplest way to consume this library out of the box.\n    </td>\n  </tr>\n  <tr>\n    <td><code>web-vitals.umd.js</code></td>\n    <td><code>pgk.main</code></td>\n    <td>\n      A UMD version of the <code>web-vitals.js</code> bundle (exposed on the <code>window.webVitals.*</code> namespace).\n    </td>\n  </tr>\n  <tr>\n    <td><code>web-vitals.iife.js</code></td>\n    <td>--</td>\n    <td>\n      An IIFE version of the <code>web-vitals.js</code> bundle (exposed on the <code>window.webVitals.*</code> namespace).\n    </td>\n  </tr>\n  <tr>\n    <td><code>web-vitals.base.js</code></td>\n    <td>--</td>\n    <td>\n      <p>An ES module bundle containing just the \"base\" part of the \"base+polyfill\" version.</p>\n      Use this bundle if (and only if) you've also added the <code>polyfill.js</code> script to the <code>&lt;head&gt;</code> of your pages. See <a href=\"#how-to-use-the-polyfill\">how to use the polyfill</a> for more details.\n    </td>\n  </tr>\n    <tr>\n    <td><code>web-vitals.base.umd.js</code></td>\n    <td>--</td>\n    <td>\n      A UMD version of the <code>web-vitals.base.js</code> bundle (exposed on the <code>window.webVitals.*</code> namespace).\n    </td>\n  </tr>\n  </tr>\n    <tr>\n    <td><code>web-vitals.base.iife.js</code></td>\n    <td>--</td>\n    <td>\n      An IIFE version of the <code>web-vitals.base.js</code> bundle (exposed on the <code>window.webVitals.*</code> namespace).\n    </td>\n  </tr>\n  <tr>\n    <td><code>polyfill.js</code></td>\n    <td>--</td>\n    <td>\n      <p>The \"polyfill\" part of the \"base+polyfill\" version. This script should be used with either <code>web-vitals.base.js</code>, <code>web-vitals.base.umd.js</code>, or <code>web-vitals.base.iife.js</code> (it will not work with any script that doesn't have \"base\" in the filename).</p>\n      See <a href=\"#how-to-use-the-polyfill\">how to use the polyfill</a> for more details.\n    </td>\n  </tr>\n</table>\n\n### Which bundle is right for you?\n\nMost developers will generally want to use the \"standard\" bundle (either the ES module or UMD version, depending on your build system), as it's the easiest to use out of the box and integrate into existing build tools.\n\nHowever, there are a few good reasons to consider using the \"base+polyfill\" version, for example:\n\n- FID can be measured in all browsers.\n- CLS, FCP, FID, and LCP will be more accurate in some cases (since the polyfill detects the page's initial `visibilityState` earlier).\n\n### How the polyfill works\n\nThe `polyfill.js` script adds event listeners (to track FID cross-browser), and it records initial page visibility state as well as the timestamp of the first visibility change to hidden (to improve the accuracy of CLS, FCP, LCP, and FID).\n\nIn order for it to work properly, the script must be the first script added to the page, and it must run before the browser renders any content to the screen. This is why it needs to be added to the `<head>` of the document.\n\nThe \"standard\" version of the `web-vitals` library includes some of the same logic found in `polyfill.js`. To avoid duplicating that code when using the \"base+polyfill\" version, the `web-vitals.base.js` bundle does not include any polyfill logic, instead it coordinates with the code in `polyfill.js`, which is why the two scripts must be used together.\n\n## API\n\n### Types:\n\n#### `Metric`\n\n```ts\ninterface Metric {\n  // The name of the metric (in acronym form).\n  name: 'CLS' | 'FCP' | 'FID' | 'LCP' | 'TTFB';\n\n  // The current value of the metric.\n  value: number;\n\n  // The delta between the current value and the last-reported value.\n  // On the first report, `delta` and `value` will always be the same.\n  delta: number;\n\n  // A unique ID representing this particular metric that's specific to the\n  // current page. This ID can be used by an analytics tool to dedupe\n  // multiple values sent for the same metric, or to group multiple deltas\n  // together and calculate a total.\n  id: string;\n\n  // Any performance entries used in the metric value calculation.\n  // Note, entries will be added to the array as the value changes.\n  entries: (PerformanceEntry | FirstInputPolyfillEntry | NavigationTimingPolyfillEntry)[];\n}\n```\n\n#### `ReportHandler`\n\n```ts\ninterface ReportHandler {\n  (metric: Metric): void;\n}\n```\n\n#### `FirstInputPolyfillEntry`\n\nWhen using the FID polyfill (and if the browser doesn't natively support the Event Timing API), `metric.entries` will contain an object that polyfills the `PerformanceEventTiming` entry:\n\n```ts\ntype FirstInputPolyfillEntry = Omit<PerformanceEventTiming,\n  'processingEnd' | 'processingEnd' | 'toJSON'>\n```\n\n#### `FirstInputPolyfillCallback`\n\n```ts\ninterface FirstInputPolyfillCallback {\n  (entry: FirstInputPolyfillEntry): void;\n}\n```\n\n#### `NavigationTimingPolyfillEntry`\n\nWhen calling `getTTFB()`, if the browser doesn't support the [Navigation Timing API Level 2](https://www.w3.org/TR/navigation-timing-2/) interface, it will polyfill the entry object using timings from `performance.timing`:\n\n```ts\nexport type NavigationTimingPolyfillEntry = Omit<PerformanceNavigationTiming,\n  'initiatorType' | 'nextHopProtocol' | 'redirectCount' | 'transferSize' |\n  'encodedBodySize' | 'decodedBodySize' | 'toJSON'>\n```\n\n#### `WebVitalsGlobal`\n\nIf using the \"base+polyfill\" build, the `polyfill.js` script creates the global `webVitals` namespace matching the following interface:\n\n```ts\ninterface WebVitalsGlobal {\n  firstInputPolyfill: (onFirstInput: FirstInputPolyfillCallback) => void;\n  resetFirstInputPolyfill: () => void;\n  firstHiddenTime: number;\n}\n```\n\n### Functions:\n\n#### `getCLS()`\n\n```ts\ntype getCLS = (onReport: ReportHandler, reportAllChanges?: boolean) => void\n```\n\nCalculates the [CLS](https://web.dev/cls/) value for the current page and calls the `onReport` function once the value is ready to be reported, along with all `layout-shift` performance entries that were used in the metric value calculation. The reported value is a [double](https://heycam.github.io/webidl/#idl-double) (corresponding to a [layout shift score](https://web.dev/cls/#layout-shift-score)).\n\nIf the `reportAllChanges` param is `true`, the `onReport` function will be called any time a new `layout-shift` performance entry is dispatched, or once the final value of the metric has been determined.\n\n_**Important:** unlike other metrics, CLS continues to monitor changes for the entire lifespan of the page&mdash;including if the user returns to the page after it's been hidden/backgrounded. However, since browsers often [will not fire additional callbacks once the user has backgrounded a page](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#advice-hidden), `onReport` is always called when the page's visibility state changes to hidden. As a result, the `onReport` function might be called multiple times during the same page load (see [Reporting only the delta of changes](#report-only-the-delta-of-changes) for how to manage this)._\n\n#### `getFCP()`\n\n```ts\ntype getFCP = (onReport: ReportHandler, reportAllChanges?: boolean) => void\n```\n\nCalculates the [FCP](https://web.dev/fcp/) value for the current page and calls the `onReport` function once the value is ready, along with the relevant `paint` performance entry used to determine the value. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp).\n\n#### `getFID()`\n\n```ts\ntype getFID = (onReport: ReportHandler, reportAllChanges?: boolean) => void\n```\n\nCalculates the [FID](https://web.dev/fid/) value for the current page and calls the `onReport` function once the value is ready, along with the relevant `first-input` performance entry used to determine the value (and optionally the input event if using the [FID polyfill](#fid-polyfill)). The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp).\n\n_**Important:** since FID is only reported after the user interacts with the page, it's possible that it will not be reported for some page loads._\n\n#### `getLCP()`\n\n```ts\ntype getLCP = (onReport: ReportHandler, reportAllChanges?: boolean) => void\n```\n\nCalculates the [LCP](https://web.dev/lcp/) value for the current page and calls the `onReport` function once the value is ready (along with the relevant `largest-contentful-paint` performance entries used to determine the value). The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp).\n\nIf the `reportAllChanges` param is `true`, the `onReport` function will be called any time a new `largest-contentful-paint` performance entry is dispatched, or once the final value of the metric has been determined.\n\n#### `getTTFB()`\n\n```ts\ntype getTTFB = (onReport: ReportHandler, reportAllChanges?: boolean) => void\n```\n\nCalculates the [TTFB](https://web.dev/time-to-first-byte/) value for the current page and calls the `onReport` function once the page has loaded, along with the relevant `navigation` performance entry used to determine the value. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp).\n\nNote, this function waits until after the page is loaded to call `onReport` in order to ensure all properties of the `navigation` entry are populated. This is useful if you want to report on other metrics exposed by the [Navigation Timing API](https://w3c.github.io/navigation-timing/).\n\nFor example, the TTFB metric starts from the page's [time origin](https://www.w3.org/TR/hr-time-2/#sec-time-origin), which means it [includes](https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing#the_life_and_timings_of_a_network_request) time spent on DNS lookup, connection negotiation, network latency, and unloading the previous document. If, in addition to TTFB, you want a metric that excludes these timings and _just_ captures the time spent making the request and receiving the first byte of the response, you could compute that from data found on the performance entry:\n\n```js\nimport {getTTFB} from 'web-vitals';\n\ngetTTFB((metric) => {\n  // Calculate the request time by subtracting from TTFB\n  // everything that happened prior to the request starting.\n  const requestTime = metric.value - metric.entries[0].requestStart;\n  console.log('Request time:', requestTime);\n});\n```\n\n_**Note:** browsers that do not support `navigation` entries will fall back to\nusing `performance.timing` (with the timestamps converted from epoch time to [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp)). This ensures code referencing these values (like in the example above) will work the same in all browsers._\n\n## Browser Support\n\nThe `web-vitals` code has been tested and will run without error in all major browsers as well as Internet Explorer back to version 9. However, some of the APIs required to capture these metrics are currently only available in Chromium-based browsers (e.g. Chrome, Edge, Opera, Samsung Internet).\n\nBrowser support for each function is as follows:\n\n- `getCLS()`: Chromium,\n- `getFCP()`: Chromium, Firefox, Safari\n- `getFID()`: Chromium, Firefox, Safari, Internet Explorer (with the [polyfill](#how-to-use-the-polyfill))\n- `getLCP()`: Chromium\n- `getTTFB()`: Chromium, Firefox, Safari, Internet Explorer\n\n## Limitations\n\nThe `web-vitals` library is primarily a wrapper around the Web APIs that\nmeasure the Web Vitals metrics, which means the limitations of those APIs will\nmostly apply to this library as well.\n\nThe primary limitation of these APIs is they have no visibility into `<iframe>` content (not even same-origin iframes), which means pages that make use of iframes will likely see a difference between the data measured by this library and the data available in the Chrome User Experience Report (which does include iframe content).\n\nFor same-origin iframes, it's possible to use the `web-vitals` library to measure metrics, but it's tricky because it requires the developer to add the library to every frame and `postMessage()` the results to the parent frame for aggregation.\n\n_**Note:** given the lack of iframe support, the `getCLS()` function technically measures [DCLS](https://github.com/wicg/layout-instability#cumulative-scores) (Document Cumulative Layout Shift) rather than CLS, if the page includes iframes)._\n\n## Development\n\n### Building the code\n\nThe `web-vitals` source code is written in TypeScript. To transpile the code and build the production bundles, run the following command.\n\n```sh\nnpm run build\n```\n\nTo build the code and watch for changes, run:\n\n```sh\nnpm run watch\n```\n\n### Running the tests\n\nThe `web-vitals` code is tested in real browsers using [webdriver.io](https://webdriver.io/). Use the following command to run the tests:\n\n```sh\nnpm test\n```\n\nTo test any of the APIs manually, you can start the test server\n\n```sh\nnpm run test:server\n```\n\nThen navigate to `http://localhost:9090/test/<view>`, where `<view>` is the basename of one the templates under [/test/views/](/test/views/).\n\nYou'll likely want to combine this with `npm run watch` to ensure any changes you make are transpiled and rebuilt.\n\n## Integrations\n\n- [**Web Vitals Connector**](https://goo.gle/web-vitals-connector): Data Studio connector to create dashboards from [Web Vitals data captured in BiqQuery](https://web.dev/vitals-ga4/).\n- [**Core Web Vitals Custom Tag template**](https://www.simoahava.com/custom-templates/core-web-vitals/): Custom GTM template tag to [add measurement handlers](https://www.simoahava.com/analytics/track-core-web-vitals-in-ga4-with-google-tag-manager/) for all Core Web Vitals metrics.\n- [**`web-vitals-reporter`**](https://github.com/treosh/web-vitals-reporter): JavaScript library to batch `onReport` callbacks and send data with a single request.\n\n## License\n\n[Apache 2.0](/LICENSE)\n",
    "licenseText": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2020 Google LLC\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       https://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  "artifacts": [],
  "remote": {
    "resolved": "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.1.4.tgz#76563175a475a5e835264d373704f9dde718290c",
    "type": "tarball",
    "reference": "https://registry.yarnpkg.com/web-vitals/-/web-vitals-2.1.4.tgz",
    "hash": "76563175a475a5e835264d373704f9dde718290c",
    "integrity": "sha512-sVWcwhU5mX6crfI5Vd2dC4qchyTqxV8URinzt25XqVh+bHEPGH4C3NPrNionCP7Obx59wrYEbNlw4Z8sjALzZg==",
    "registry": "npm",
    "packageName": "web-vitals",
    "cacheIntegrity": "sha512-sVWcwhU5mX6crfI5Vd2dC4qchyTqxV8URinzt25XqVh+bHEPGH4C3NPrNionCP7Obx59wrYEbNlw4Z8sjALzZg== sha1-dlYxdaR1peg1Jk03NwT53ecYKQw="
  },
  "registry": "npm",
  "hash": "76563175a475a5e835264d373704f9dde718290c"
}