react-vitals
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

React Vitals

React components, hooks and utilities to improve web vitals scores (FCP, LCP, CLS, INP)

DelayLoad

The <DelayLoad/> component delay the rendering of children, to not affect FCP, LCP and CLS. It is useful for non-important and even annoying content, like advertise blocks, survey popups, etc. You can use timeout prop (default: 3000) to control maximum milliseconds to wait before rendering. Usually, timeout should be larger than the LCP you want to achieve.

import { DelayLoad } from 'react-vitals';

const Advertise = () => <div style={{ height: 400, background: 'orange' }}>Advertise loaded!</div>;
const Survey = () => <div style={{ height: 400, background: 'green' }}>Survey loaded!</div>;

render(
  <DelayLoad timeout={100}>
    <Advertise />
    <Survey />
  </DelayLoad>,
);

Package Sidebar

Install

npm i react-vitals

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

7.65 kB

Total Files

12

Last publish

Collaborators

  • guoyunhe