Giter Club home page Giter Club logo

franklin-plugin-perflogger's Introduction

franklin-plugin-perflogger

A performance logger plugin for Franklin that will output key performance metrics (core web vitals and a few others) to console. It is meant to be used with this forked Franklin Project Boilerplate that includes a plugin system.

The performance logger won't be as accurate as proper solutions like https://pagespeed.web.dev/ or other services that can report stable lab data, or realistic field metrics, but it does help highlight key improvement areas during development.

See it in action at https://plugins-perflogger--helix-project-boilerplate--ramboz.hlx.live/.

Install

Via the boilerplate

npm run franklin:plugin:add --name=perflogger [email protected]:ramboz/franklin-plugin-perflogger.git

You can then later update it from the source again via:

npm run franklin:plugin:update --name=perflogger

Manually

git subtree add --squash --prefix plugins/perflogger [email protected]:ramboz/franklin-plugin-perflogger.git main

You can then later update it from the source again via:

git subtree pull --squash --prefix plugins/perflogger [email protected]:ramboz/franklin-plugin-perflogger.git main

Usage

Via the plugin system

The easiest is to load the plugin via the withPlugin method provided in this forked Franklin Project Boilerplate.

import { withPlugin } from './lib-franklin.js';

...

await withPlugin('/plugins/perflogger/index.js', {
  condition: () => window.location.hostname === 'localhost' || window.location.origin.endsWith('.hlx.page')
});

Manually

Alternatively, you can also just directly use this as:

if (window.location.hostname === 'localhost' || window.location.origin.endsWith('.hlx.page')) {
  const logger = await import('/plugins/perflogger/index.js');
  logger.init(options);
}

by making sure you place the init call as close to the beginning of your script as possible, so you don't miss the events that are tracked.

Configuration

Name Default Type Description
cls true boolean Tracks cumulative layout shifts events
dcl true boolean Tracks the DOMContentLoaded and load events
fcp true boolean Tracks the first contentful paint event
fid true boolean Tracks the first input delay event
fp true boolean Tracks the first paint event
lcp true boolean Tracks the largest contentful paint event
tbt true boolean Tracks the long tasks events contributing to the total blocking time
resources true boolean Tracks the load event for each resource
debug false boolean Logs more fine-grained details for every event

You'd use those as follows:

await withPlugin('/plugins/perflogger/index.js', {
  debug: true,
  cls: true,
  dcl: true,
  fcp: true,
  fid: true,
  fp: true,
  lcp: true,
  resources: true,
  tbt: true,
});

franklin-plugin-perflogger's People

Contributors

ramboz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ghas-results

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.