简体   繁体   English

与 create-react-app 一起出现的 web-vitals 是什么?

[英]What is the web-vitals, comming with create-react-app?

I have just recognised that my newly created Reactjs application have a file src/reportWebVitals.js , which is being called in index.js.我刚刚认识到我新创建的 Reactjs 应用程序有一个文件src/reportWebVitals.js ,它在 index.js 中被调用。 What is this file/pice of code for?这个文件/代码的用途是什么?

const reportWebVitals = onPerfEntry => {
  if (onPerfEntry && onPerfEntry instanceof Function) {
    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
      getCLS(onPerfEntry);
      getFID(onPerfEntry);
      getFCP(onPerfEntry);
      getLCP(onPerfEntry);
      getTTFB(onPerfEntry);
    });
  }
};

export default reportWebVitals;

It is a third-party library is used to capture and measure user experience metrics comming as a default with create-react-app .它是一个第三方库,用于捕获和测量默认与create-react-app一起使用的用户体验指标。

The web-vitals library is a tiny (~1K), modular library for measuring all the Web Vitals metrics on real users, in a way that accurately matches how they're measured by Chrome and reported to other Google tools (eg Chrome User Experience Report, Page Speed Insights, Search Console's Speed Report). web-vitals 库是一个小型(~1K)模块化库,用于测量真实用户的所有 Web Vitals 指标,其方式与 Chrome 测量这些指标并报告给其他 Google 工具(例如 Chrome 用户体验)的方式准确匹配报告、Page Speed Insights、Search Console 的速度报告)。

They are grouped under two title;它们分为两个标题;

  1. Core Web Vitals核心 Web Vitals
  • Cumulative Layout Shift ( CLS )累积布局偏移 ( CLS )
  • First Input Delay ( FID )第一输入延迟 ( FID )
  • Largest Contentful Paint ( LCP ) Largest Contentful Paint( LCP
  1. Other Web Vitals其他 Web 生命体征
  • First Contentful Paint ( FCP ) First Contentful Paint( FCP
  • Time to First Byte ( TTFB )首字节时间 ( TTFB )

for more detail -> https://github.com/GoogleChrome/web-vitals了解更多详情 -> https://github.com/GoogleChrome/web-vitals

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React JS“npm start”显示无法编译 web-vitals - React JS "npm start" shows failed to complile web-vitals React JS npm 启动显示编译web-vitals失败 - React JS npm start shows failed to compile web-vitals 未找到模块:错误:无法解析“/app/src”中的“web-vitals” - Module not found: Error: Can't resolve 'web-vitals' in '/app/src' 在 Heroku 上构建:./src/reportWebVitals.js - 找不到模块:无法解析“/app/src”中的“web-vitals” - Building on the Heroku : ./src/reportWebVitals.js - Module not found: Can't resolve 'web-vitals' in '/app/src' Create-react-app (Web) 中的推送通知 - Push notification in Create-react-app (Web) create-react-app 的缺点是什么? - What are the drawbacks of create-react-app? 使用 babel & web pack with react without create-react-app - Using babel & web pack with react without create-react-app 在React中使用Nightmare网络抓取(create-react-app) - Using Nightmare web-scraping with React (create-react-app) 反应由 CRA(create-react-app) 创建的 web 总是重定向到 '/' - react web created by CRA(create-react-app) always redirect to '/' 'create-react-app 有什么区别<project> ' 和 'yarn create-react-app<project> '?</project></project> - What is the difference 'create-react-app <project>' and 'yarn create-react-app <project>'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM