← All tasks
javascriptGoogleChrome/web-vitals #259Not a task: not reproduced

Question: what changed to cause `webVitals` to be `undefined` when loading `https://unpkg.com/web-vitals` as previously documented?

envgap__GoogleChrome__web-vitals-259

01 / FAILURE SIGNATURE

As reported upstream

Hello - I provide a service and encouraged several users to consume the Web Vitals library as documented. I've been receiving complaints of an error that users are seeing who have loaded the Web Vitals library.
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
e502fab81b45219ac41d5c771a9e5a0928d952bb
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

GoogleChrome/web-vitals #259 · read the original issue
Hello - I provide a service and encouraged several users to consume the Web Vitals library as documented. I've been receiving complaints of an error that users are seeing who have loaded the Web Vitals library.



```

webVitals is undefined

```

I've pinpointed a common denominator that those who have this issue are using the previous example from the docs:



```html

<!-- Without the `?module` param, the UMD version is loaded and sets the `webVitals` global -->

<script defer src="https://unpkg.com/web-vitals"></script>

<script>

  addEventListener('DOMContentLoaded', function() {

    webVitals.getCLS(console.log);

    webVitals.getFID(console.log);

    webVitals.getLCP(console.log);

  });

</script>

```



Which has been replaced with this:



```html

<script>

  (function() {

    var script = document.createElement('script');

    script.src = 'https://unpkg.com/web-vitals/dist/web-vitals.iife.js';

    script.onload = function() {

      webVitals.getCLS(console.log);

      webVitals.getFID(console.log);

      webVitals.getLCP(console.log);

    }

    document.head.appendChild(script);

  }())

</script>

```



I did reproduce the error and replacing it with the new snippet fixes the issue.



It seems that this change occurred in 9f9a2cc29. From my perspective this is a breaking change. Am I mistaken? What changed in `https://unpkg.com/web-vitals` in which the library doesn't support the original example? I'd love to have this data to pass along to my users and so I can apologize that their implementation unexpectedly stopped working and explain why.



I'm probably missing something... some announcement, etc. Or at least was there a PR that explained this change?



Any info that I can pass along would be appreciated.



Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]