v3.ocaml.org-rescript icon indicating copy to clipboard operation
v3.ocaml.org-rescript copied to clipboard

Implement a reusable img component

Open ghost opened this issue 4 years ago • 2 comments

Various pages on the site make use of the img tag. Let's implement a reusable Img React component, which provides a simpler interface and sensible defaults. This issue is similar to #427.

ghost avatar Jun 11 '21 14:06 ghost

As part of this issue, it would be useful to research best practices on when to use background images versus an image tag for decorative images. This component could provide a parameter to pick the appropriate implementation.

ghost avatar Jun 29 '21 10:06 ghost

For image tags:

  • next/image already applies various best practices: https://nextjs.org/docs/api-reference/next/image
  • height + width should ALWAYS be supplied, because in tandem they behave as an aspect ratio, give the image a non empty bounding box on download, then actual height/width may be overridden using CSS. this improves CLS metric. Jen Simmons has a video on it

for either type of image, likely preload it if it is top of page or in the header

cdaringe avatar Aug 29 '21 15:08 cdaringe