Skip to content

Add JS build step to utilize local copy of web-vitals.js #893

@westonruter

Description

@westonruter

Feature Description

As noted in #876 (comment), the Image Loading Optimization module (see #869) is currently loading web-vitals.js directly from unpkg.com:

// TODO: Use a local copy of web-vitals.
const { onLCP } = await import(
// eslint-disable-next-line import/no-unresolved
'https://unpkg.com/web-vitals@3/dist/web-vitals.js?module'
);

This is not ideal from a performance perspective (due to the additional DNS lookup) nor from a privacy perspective (potentially). In any case, for any future consideration for merging this module into WordPress core, a local copy off the JS file will certainly be required.

A build process is also needed for the proposed Partytown module (#556 (comment)).

In short, I believe this would entail having a new command added to the npm scripts which would copy the web-vitals.js module script into the plugin, while keeping this copy .gitignore'ed. This file would nevertheless need to be included in any PerfLab plugin ZIP/deploy or when eventually when the standalone plugin is built.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions