Skip to content

Instantly share code, notes, and snippets.

@mbaumbach
mbaumbach / WebVitalsWidget.tsx
Last active June 24, 2023 18:54
WebVitalsWidget
// Requires: web-vitals package to be added to your package.json dependencies.
// Usage: <WebVitalsWidget enabled />
// Ideally you should mount this component as high as you can in your component hierarchy so it renders ASAP.
// You can set the enabled prop to use an environment variable to make sure it's only on in dev/staging and off in prod if you want.
// You can add a query parameter of __vitals=true to the end of your URL at any time and it will trigger the widget to show.
// If the widget is covering an important part of your app, you can move it around with the location prop.
// Some data won't populate in the widget until you click somewhere on the page to bring focus to the window (LCP/FID)
import java.util.concurrent.TimeUnit;
import liqp.Template;
public class Playground {
private static void parse(String template) {
for (int i = 0; i < 10; i++) {
long start = System.nanoTime();
Template.parse(template);