npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webperf-monitor-krishna

v1.0.1

Published

A comprehensive web performance monitoring package for tracking DOM elements and JavaScript functions

Downloads

5

Readme

webperf-monitor

A comprehensive web performance monitoring package for tracking DOM elements, JavaScript functions, and simulating load in web applications.

Features

  • 🚀 Function Performance Monitoring: Track execution time and memory usage of JavaScript functions
  • 🎯 DOM Element Monitoring: Attach listeners to buttons or DOM elements and monitor user interactions (via Puppeteer)
  • 🔄 Load Simulation: Simulate user traffic to evaluate performance under load (via Puppeteer)
  • 📊 Data Export: Export structured performance logs in JSON/CSV formats
  • 📈 Visual Reports: Generate charts and visual reports for performance analysis
  • 🛠️ Multiple Interfaces: Both programmatic API and CLI interface
  • 📝 Advanced Logging: Use PerformanceLogger for custom/advanced logging

Installation

From npm

npm install webperf-monitor

From GitHub (latest)

npm install git+https://github.com/krishnasharma0101/webperf-monitor.git

Quick Start

Programmatic Usage

Monitor a Function

import { monitorFunction } from 'webperf-monitor';

const result = await monitorFunction(
  () => expensiveCalculation(),
  'expensive-calculation',
  {
    logToFile: true,
    logToConsole: true,
    includeMemory: true,
    outputDir: './logs',
    format: 'json',
    filename: 'expensive-calc',
    append: true
  }
);
console.log(result);

Monitor DOM Elements (via Puppeteer)

import { monitorElement } from 'webperf-monitor';

await monitorElement(
  'https://example.com',
  '#submit-button',
  {
    events: ['click', 'focus'],
    logToFile: true,
    logToConsole: true,
    timeout: 10000,
    outputDir: './logs',
    format: 'json',
    filename: 'element-events',
    append: true
  }
);

Simulate Load (via Puppeteer)

import { simulateLoad } from 'webperf-monitor';

await simulateLoad({
  target: 'https://example.com',
  concurrency: 10,
  duration: 60000, // ms
  interval: 1000, // ms between requests
  actions: [
    { type: 'click', selector: '#login' },
    { type: 'type', selector: '#username', value: 'user' },
    { type: 'type', selector: '#password', value: 'pass' },
    { type: 'click', selector: '#submit' }
  ],
  logToFile: true,
  logSummaryToFile: true,
  outputDir: './logs',
  filename: 'load-test',
  format: 'json',
  append: true
});

CLI Usage

# Monitor a function in a file (see sample-func.js)
node bin/cli.js function --file ./sample-func.js --function add

# Monitor a slow async function
node bin/cli.js function --file ./sample-func.js --function slow

# Monitor a function that throws
node bin/cli.js function --file ./sample-func.js --function fail

# Monitor DOM element (headless, via Puppeteer)
node bin/cli.js element --url https://example.com --selector 'h1' --events click --timeout 5000

# Simulate load
done bin/cli.js load --url https://example.com --concurrency 2 --duration 10000 --interval 2000

API Reference

monitorFunction(fn, label, options?)

Monitors the execution of a function and returns performance metrics.

Parameters:

  • fn: Function to monitor
  • label: Label for the function in logs
  • options: Optional configuration (see below)

Returns: Promise with { result, metrics }

Options for monitorFunction

  • logToFile (boolean): Log metrics to file
  • logToConsole (boolean): Log metrics to console
  • includeMemory (boolean): Include memory usage
  • outputDir (string): Directory for logs
  • format (string): 'json' or 'csv'
  • filename (string): Log file name
  • append (boolean): Append to log file

monitorElement(url, selector, config)

Attaches performance monitoring listeners to DOM elements (via Puppeteer).

Parameters:

  • url: URL to open
  • selector: CSS selector for the element
  • config: Configuration object (see below)

Config for monitorElement

  • events (array): Events to monitor (e.g., ['click', 'focus'])
  • logToFile, logToConsole, timeout, outputDir, format, filename, append (see above)

simulateLoad(options)

Simulates user traffic to evaluate performance under load (via Puppeteer).

Parameters:

  • options.target: Target URL
  • options.concurrency: Number of concurrent users
  • options.duration: Test duration in ms
  • options.interval: Interval between requests (ms)
  • options.actions: Array of user actions (click, type, wait, navigate)
  • logToFile, logSummaryToFile, outputDir, filename, format, append (see above)

Advanced Usage: PerformanceLogger

You can use the PerformanceLogger class directly for custom logging:

import { PerformanceLogger } from 'webperf-monitor';
const logger = new PerformanceLogger({ outputDir: './logs', format: 'json' });
await logger.log({ executionTime: 123, label: 'custom', timestamp: Date.now(), success: true });

Configuration

The package supports various configuration options for logging, reporting, and monitoring behavior. See the API reference above for details.

Cleaning the Directory for GitHub

Before pushing to GitHub, make sure to:

  • Remove or gitignore logs/: Performance logs and test outputs should not be committed.
  • Remove or gitignore dist/: Build outputs should not be committed (add to .gitignore).
  • Remove or gitignore node_modules/: Never commit dependencies.
  • Remove test and sample files: Remove test.js, test-file-logging.js, and sample-func.js if not needed for the published package.

License

MIT