Skip to content

Instantly share code, notes, and snippets.

@philipwalton
Last active July 20, 2020 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save philipwalton/fcf8be306f6bd383119d8391947ac3a8 to your computer and use it in GitHub Desktop.
Save philipwalton/fcf8be306f6bd383119d8391947ac3a8 to your computer and use it in GitHub Desktop.
Measure the Core Web Vitals without a bundler
<!-- Load `web-vitals` using a module script. -->
<script type="module">
import {getCLS, getFID, getLCP} from 'https://unpkg.com/web-vitals@0.2.1/dist/web-vitals.es5.min.js?module';
getCLS(console.log);
getFID(console.log);
getLCP(console.log);
</script>
<!-- Load `web-vitals` using a classic script that sets the global `webVitals` object. -->
<script defer src="https://unpkg.com/web-vitals@0.2.1/dist/web-vitals.es5.umd.min.js"></script>
<script>
addEventListener('DOMContentLoaded', function() {
webVitals.getCLS(console.log);
webVitals.getFID(console.log);
webVitals.getLCP(console.log);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment