All Projects → Zizzamia → Perfume.js

Zizzamia / Perfume.js

Licence: mit
Web performance library for measuring all User-centric performance metrics

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Perfume.js

Nemetric
前端性能指标的监控,采集以及上报。用于测量第一个dom生成的时间(FP/FCP/LCP)、用户最早可操作时间(fid|tti)和组件的生命周期性能,,网络状况以及资源大小等等。向监控后台报告实际用户测量值。
Stars: ✭ 145 (-94.28%)
Mutual labels:  metrics, performance-monitoring, performance, web-performance
Scouter
Scouter is an open source APM (Application Performance Management) tool.
Stars: ✭ 1,792 (-29.25%)
Mutual labels:  metrics, performance-monitoring, performance
instant-vitals
Simple tools to track and improve your Web Vitals scores
Stars: ✭ 103 (-95.93%)
Mutual labels:  lcp, cls, fid
Snmpcollector
A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB
Stars: ✭ 216 (-91.47%)
Mutual labels:  metrics, performance-monitoring, performance
Myperf4j
High performance Java APM. Powered by ASM. Try it. Test it. If you feel its better, use it.
Stars: ✭ 2,281 (-9.95%)
Mutual labels:  metrics, performance-monitoring, performance
App perf
Open source application performance monitoring tool with emphasis on ease of setup and use. Providing similar functionality like NewRelic/AppNeta/Skylight etc.
Stars: ✭ 353 (-86.06%)
Mutual labels:  metrics, performance-monitoring, performance
Garie
Open source web performance
Stars: ✭ 484 (-80.89%)
Mutual labels:  metrics, performance, web-performance
Awesome Pagespeed Metrics
⚡Metrics to help understand page speed and user experience
Stars: ✭ 585 (-76.9%)
Mutual labels:  metrics, performance, web-performance
Browser Perf
Performance Metrics for Web Browsers
Stars: ✭ 930 (-63.28%)
Mutual labels:  metrics, performance, web-performance
Opbeat Node
DEPRECATED - See Elastic APM instead: https://github.com/elastic/apm-agent-nodejs
Stars: ✭ 155 (-93.88%)
Mutual labels:  metrics, performance-monitoring, performance
Web Vitals Module
Web Vitals: Essential module for a healthy Nuxt.js
Stars: ✭ 138 (-94.55%)
Mutual labels:  metrics, performance
Perf Tools
⏱→ 🚀A set of tools for improving performance your application (balancer, performance, PerfKeeper, LazyPromise).
Stars: ✭ 135 (-94.67%)
Mutual labels:  metrics, performance
Grofer
A system and resource monitoring tool written in Golang!
Stars: ✭ 135 (-94.67%)
Mutual labels:  performance-monitoring, performance
Stagemonitor
an open source solution to application performance monitoring for java server applications
Stars: ✭ 1,664 (-34.31%)
Mutual labels:  metrics, performance
Swiftmetrics
Swift Application Metrics instruments the Swift runtime for performance monitoring, providing the monitoring data programatically via an API or visually with an Eclipse Client.
Stars: ✭ 145 (-94.28%)
Mutual labels:  metrics, performance-monitoring
Web Vitals Extension
A Chrome extension to measure essential metrics for a healthy site
Stars: ✭ 1,943 (-23.29%)
Mutual labels:  performance, web-performance
Goose
Load testing tool, inspired by Locust
Stars: ✭ 151 (-94.04%)
Mutual labels:  metrics, performance
Icinga2
Icinga is a monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting.
Stars: ✭ 1,670 (-34.07%)
Mutual labels:  metrics, performance
React Live Chat Loader
Implement a live chat beacon in your React application without performance regressions.
Stars: ✭ 145 (-94.28%)
Mutual labels:  performance, web-performance
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (-21.59%)
Mutual labels:  metrics, performance
Perfume.js logo

Perfume.js v6.3.0

Current version Test Coverage No dependencies Build Status NPM Downloads gzip size brotli size

Page Speed is a feature, and to deliver it we need to understand the many factors and fundamental limitations that are at play. If we can measure it, we can improve it.





English | 简体中文 | Italian | 한국어

Why Perfume.js?

Perfume is a tiny, web performance monitoring library that reports field data back to your favorite analytics tool.

  • Supports latest Performance APIs for precise metrics
  • 🚀 Device data enrichment
  • 🔨 Cross browser tested
  • 🚿 Filters out false positive/negative results
  • 🤙 Only 2.2Kb gzip
  • 🏅 Web Vitals Score
  • 🛰 Flexible analytics tool
  • ⚡️ Waste-zero ms with requestIdleCallback strategy built-in

The latest in metrics & Real User Measurement

Perfume leverages the latest Performance APIs to collect field data that allows us to understand what real-world users are actually experiencing.

  • Navigation Timing
  • Navigator Interface
  • Resource Timing
  • Element Timing
  • Service Worker Status
  • StorageManager interface
  • First Paint (FP)
  • First Contentful Paint (FCP)
  • Largest Contentful Paint (LCP)
  • First Input Delay (FID)
  • Cumulative Layout Shift (CLS)
  • Total Blocking Time (TBT)
  • Web Vitals Score

With Perfume.js, you can collect these metrics to develop a deeper understanding of how customers around the world perceive web performance for your application.
Use your favorite analytics tool to visualize the data from country to country. Take a look at this example comparing FCP for www.coinbase.com in the United States, Italy, Indonesia, and Nigeria.

First Contentful Paint

Installing

npm (https://www.npmjs.com/package/perfume.js):

npm install perfume.js --save

Importing library

You can import the generated bundle to use the whole library generated:

import Perfume from 'perfume.js';

Universal Module Definition:

import Perfume from 'node_modules/perfume.js/dist/perfume.umd.min.js';

Quick start

Metrics like Navigation Timing, Network Information, FP, FCP, FID, LCP, CLS and TBT are default reported with Perfume; All results will be reported to the analyticsTracker callback, and the code below is just one way for you to organize your tracking, feel free to tweak it suit your needs.

🚀 Visit perfumejs.com for a live demo on how the metrics work. 🌕

const perfume = new Perfume({
  analyticsTracker: options => {
    const {
      metricName,
      data,
      eventProperties,
      navigatorInformation,
      vitalsScore,
    } = options;
    switch (metricName) {
      case 'navigationTiming':
        if (data && data.timeToFirstByte) {
          myAnalyticsTool.track('navigationTiming', data);
        }
        break;
      case 'networkInformation':
        if (data && data.effectiveType) {
          myAnalyticsTool.track('networkInformation', data);
        }
        break;
      case 'storageEstimate':
        myAnalyticsTool.track('storageEstimate', data);
        break;
      case 'ttfb':
        myAnalyticsTool.track('ttfb', { duration: data });
        break;
      case 'fp':
        myAnalyticsTool.track('firstPaint', { duration: data });
        break;
      case 'fcp':
        myAnalyticsTool.track('firstContentfulPaint', { duration: data });
        break;
      case 'fid':
        myAnalyticsTool.track('firstInputDelay', { duration: data });
        break;
      case 'lcp':
        myAnalyticsTool.track('largestContentfulPaint', { duration: data });
        break;
      case 'cls':
        myAnalyticsTool.track('cumulativeLayoutShift', { value: data });
        break;
      case 'clsFinal':
        myAnalyticsTool.track('cumulativeLayoutShiftFinal', { value: data });
        break;
      case 'tbt':
        myAnalyticsTool.track('totalBlockingTime', { duration: data });
        break;
      case 'elPageTitle':
        myAnalyticsTool.track('elementTimingPageTitle', { duration: data });
        break;
      default:
        myAnalyticsTool.track(metricName, { duration: data });
        break;
    }
  },
});

In a world with widely varying device capabilities, a one-size-fits-all event doesn’t always work. Perfume adds data enrichment to all events so we can better understand the real world experiences:

  • deviceMemory: the user's device memory (RAM).
  • hardwareConcurrency: the number of logical CPU processor cores on the user's device.
  • serviceWorkerStatus: status of the service worker between controlled, supported and unsupported.

Based on the Navigator APIs the library can help us differentiate between a low-end and a high-end device/experience:

  • isLowEndDevice: combination of the score of RAM and CPU.
  • isLowEndExperience: combination of the score of RAM, CPU, NetworkStatus and SaveData.

Performance audits

Coo coo coo cool, let's learn something new.

Navigation Timing

Navigation Timing collects performance metrics for the life and timings of a network request.

Perfume helps expose some of the key metrics you might need.

  • Redirect time: Page redirects aren't totally inconsequential, but they might not be something you run into very often. Still, redirects add latency to requests, so measuring them may be worth the effort.
  • DNS lookup: When a user requests a URL, the Domain Name System (DNS) is queried to translate a domain to an IP address.
  • Header size: HTTP header size
  • Fetch time: Cache seek plus response time
  • Worker time: Service worker time plus response time
  • Total time: Request plus response time (network only)
  • Download time: Response time only (download)
  • Time to First Byte: The amount of time it takes after the client sends an HTTP GET request to receive the first byte of the requested resource from the server. It is the largest web page load time component taking 40 to 60% of total web page latency.
// Perfume.js: navigationTiming { ... timeToFirstByte: 192.65 }

First Paint (FP)

FP is the exact time taken for the browser to render anything as visually different from what was on the screen before navigation, e.g. a background change after a long blank white screen time.

// Perfume.js: fp 1482.00 ms

First Contentful Paint (FCP)

FCP is the exact time taken for the browser to render the first bit of content from the DOM, which can be anything from an important image, text, or even the small SVG at the bottom of the page.

// Perfume.js: fcp 2029.00 ms

Largest Contentful Paint (LCP)

LCP is an important, user-centric metric for measuring perceived load speed because it marks the point in the page load timeline when the page's main content has likely loaded—a fast LCP helps reassure the user that the page is useful.

We end the Largest Contentful Paint measure at two points: when First Input Delay happen and when the page's lifecycle state changes to hidden.

// Perfume.js: lcp 2429.00 ms

First Input Delay (FID)

FID measures the time from when a user first interacts with your site (i.e. when they click a link, tap on a button) to the time when the browser is actually able to respond to that interaction.

// Perfume.js: fid 3.20 ms

Cumulative Layout Shift (CLS)

CLS is an important, user-centric metric for measuring visual stability because it helps quantify how often users experience unexpected layout shifts—a low CLS helps ensure that the page is delightful.

We end the Cumulative Layout Shift measure at two points: when First Input Delay happen and when the page's lifecycle state changes to hidden.

// Perfume.js: cls 0.13
// Perfume.js: clsFinal 0.13

Total Blocking Time (TBT)

TBT is an important, user-centric metric for measuring load responsiveness because it helps quantify the severity of how non-interactive a page is prior to it becoming reliably interactive—a low TBT helps ensure that the page is usable.

We end the Total Blocking Time measure 10 seconds after FID.

// Perfume.js: tbt 347.07 ms

Resource Timing

Resource Timing collects performance metrics for document-dependent resources. Stuff like style sheets, scripts, images, et cetera. Perfume helps expose all PerformanceResourceTiming entries and groups data data consumption by Kb used.

const perfume = new Perfume({
  resourceTiming: true,
  analyticsTracker: ({ metricName, data }) => {
    myAnalyticsTool.track(metricName, data);
  })
});
// Perfume.js: dataConsumption { "css": 185.95, "fetch": 0, "img": 377.93, ... , "script": 8344.95 }

Annotate metrics in the DevTools

Performance.mark (User Timing API) is used to create an application-defined peformance entry in the browser's performance entry buffer.

const perfume = new Perfume({
  analyticsTracker: ({ metricName, data }) => {
    myAnalyticsTool.track(metricName, data);
  })
});
perfume.start('fibonacci');
fibonacci(400);
perfume.end('fibonacci');
// Perfume.js: fibonacci 0.14 ms

Performance Mark

Component First Paint

This metric mark the point, immediately after creating a new component, when the browser renders pixels to the screen.

const perfume = new Perfume({
  analyticsTracker: ({ metricName, data }) => {
    myAnalyticsTool.track(metricName, data);
  })
});
perfume.start('togglePopover');
$(element).popover('toggle');
perfume.endPaint('togglePopover');
// Perfume.js: togglePopover 10.54 ms

Performance

Element Timing

Track when image elements and text nodes are displayed on screen using the emerging Element Timing API specification by simply adding the elementtiming attribute with a descriptive value of your choice to HTML elements you would like to measure:

<h1 elementtiming="elPageTitle" class="title">Perfume.js</h1>
<img
  elementtiming="elHeroLogo"
  alt="Perfume.js logo"
  src="https://zizzamia.github.io/perfume/assets/perfume-logo-v5-0-0.png"
/>
const perfume = new Perfume({
  elementTiming: true,
  analyticsTracker: ({ metricName, data }) => {
    myAnalyticsTool.track(metricName, data);
  })
});

// Perfume.js: elPageTitle 256.00 ms
// Perfume.js: elHeroLogo 1234.00 ms

Web Vitals Score

Perfume will expose for all major metrics the vitals score, those can be used to improve your SEO and Google page rank.

Web Vitals Good Needs Improvement Poor
Time to First Byte (ttfb) 0-200 201-500 Over 500
Fist Paint (fp) 0-2000 2001-4000 Over 4000
First Contentful Paint (fcp) 0-2000 2001-4000 Over 4000
Largest Contentful Paint (lcp) 0-2500 2501-4000 Over 4000
First Input Delay (fid) 0-100 101-300 Over 300
Cumulative Layout Shift (cls) 0-0.1 0.11-0.25 Over 0.25
Cumulative Layout Shift Final (clsFinal) 0-2500 2501-4000 Over 4000
Total Blocking Time (tbt) 0-300 301-600 Over 600

Perfume custom options

Default options provided to Perfume.js constructor.

const options = {
  resourceTiming: false,
  elementTiming: false,
  analyticsTracker: options => {},
  maxMeasureTime: 30000,
};

Use Google Analytics

A quick way to see your page speed results on your web app is by using Google Analytics. Those GA events will show on Behavior > Site Speed > User Timings. For testing you might want to see them coming live on Realtime > Events.

Have fun

const metricNames = ['ttfb', 'fp', 'fcp', 'lcp', 'fid', 'cls', 'clsFinal', 'tbt'];
new Perfume({
  analyticsTracker: ({ metricName, data, navigatorInformation }) => {
    if (metricNames.includes(metricName)) {
      ga('send', 'event', {
        eventCategory: 'Perfume.js',
        eventAction: metricName,
        // Google Analytics metrics must be integers, so the value is rounded
        eventValue: metricName === 'cls' ? data * 1000 : data,
        eventLabel: navigatorInformation.isLowEndExperience ? 'lowEndExperience' : 'highEndExperience',
        // Use a non-interaction event to avoid affecting bounce rate
        nonInteraction: true,
      });
    }
  })
});

To connect with additional analytics providers, checkout the analytics plugin for Perfume.js.


Develop

  • npm run test: Run test suite
  • npm run build: Generate bundles and typings
  • npm run lint: Lints code

Plugins

Perfume is used by

Credits and Specs

Made with ☕️ by @zizzamia and I want to thank some friends and projects for the work they did:

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]


Copyright and license

Code and documentation copyright 2021 Leonardo Zizzamia. Code released under the MIT license. Docs released under Creative Commons.

Team


Leonardo Zizzamia
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].