
Security News
Meet the Socket Team at RSAC and BSidesSF 2025
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
perfume.js
Advanced tools
[](https://www.npmjs.org/package/perfume.js) [](https://travis-ci.org/Zizzamia/perfume.js) [, Time to Interactive (TTI), Component First Paint (CFM), annotating them to the DevTools timeline and reporting the results to Google Analytics.
When a user navigates to a web page, they're typically looking for visual feedback to reassure them that everything is going to work as expected.
Is it happening? Is it useful? Is it usable? Is it delightful? To understand when a page delivers this feedback to its users, we've defined several new metrics:
Luckily, with the addition of a few new browser APIs, measuring these metrics on real devices is finally possible without a lot of hacks or workarounds that can make performance worse.
Perfume leverage these new APIs for measuring performance that matters! ⚡️
npm (https://www.npmjs.com/package/perfume.js):
npm install perfume.js --save
You can import the generated bundle to use the whole library generated by this starter:
import Perfume from 'perfume.js';
Additionally, you can import the transpiled modules from dist/es
in case you have a modular library:
import Perfume from 'node_modules/perfume.js/dist/es/perfume';
Universal Module Definition:
import Perfume from 'node_modules/perfume.js/perfume.umd.js';
This metric mark the point, immediately after navigation, when the browser renders pixels to the screen. This is important to the user because it answers the question: is it happening?
FCP marks the point when the browser renders the first bit of content from the DOM, which may be text, an image, SVG, or even a element.
const perfume = new Perfume();
perfume.firstContentfulPaint();
// ⚡️ Perfume.js: First Contentful Paint 601 ms
Performance.mark (User Timing API) is used to create an application-defined peformance entry in the browser's performance entry buffer.
perfume.start('fibonacci');
fibonacci(400);
perfume.end('fibonacci', true);
// ⚡️ Perfume.js: fibonacci 0.14 ms
This metric mark the point, immediately after creating a new component, when the browser renders pixels to the screen.
perfume.start('togglePopover');
$(element).popover('toggle');
perfume.endPaint('togglePopover', true);
// ⚡️ Perfume.js: togglePopover 10.54 ms
Save the duration and print it out exactly the way you want it.
perfume.start('fibonacci');
fibonacci(400);
const duration = this.perfume.end('fibonacci');
perfume.log('Custom logging', duration);
// ⚡️ Perfume.js: Custom logging 0.14 ms
To enable Perfume to send your measures to Google Analytics User timing, set the option enable:true
and a custom user timing variable timingVar:"name"
.
const perfume = new Perfume();
perfume.googleAnalytics.enable = true;
perfume.googleAnalytics.timingVar = "userId";
npm t
: Run test suitenpm start
: Run npm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typingsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)Made with ☕️ by @zizzamia and I want to thank some friends and projects for the work they did:
Code and documentation copyright 2018 Leonardo Zizzamia. Code released under the MIT license. Docs released under Creative Commons.
FAQs
Web performance library for measuring all User-centric performance metrics, including the latest Web Vitals.
The npm package perfume.js receives a total of 27,249 weekly downloads. As such, perfume.js popularity was classified as popular.
We found that perfume.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
Security News
Biome's v2.0 beta introduces custom plugins, domain-specific linting, and type-aware rules while laying groundwork for HTML support and embedded language features in 2025.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.