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

@js-toolkit/web-utils

v1.68.1

Published

Web utils

Readme

@js-toolkit/web-utils

npm package license

TypeScript utilities for the browser: media, WebSocket, WebRTC, fullscreen, platform detection, responsive helpers, events, DOM, service workers, and more.

Install

yarn add @js-toolkit/web-utils
# or
npm install @js-toolkit/web-utils

Import

Use subpath imports for tree-shaking:

import { FullscreenController } from '@js-toolkit/web-utils/FullscreenController';
import { getRandomID } from '@js-toolkit/web-utils/getRandomID';
import { isMobile } from '@js-toolkit/web-utils/platform/isMobile';

API Overview

Media and Video

| Module | Description | |--------|-------------| | media/TextTracksController | HTML5 video text tracks management | | media/PipController | Picture-in-Picture controller | | media/MediaStreamController | MediaStream attach/detach | | media/Capabilities | Media type support detection | | media/timeRanges | TimeRanges utilities | | media/resetMedia | Reset media element and clear decoder buffer | | media/getMediaSource | Get MediaSource or ManagedMediaSource | | media/getSourceBuffer | Get SourceBuffer or ManagedSourceBuffer | | media/parseCueText | WebVTT cue text parser |

WebSocket and WebRTC

| Module | Description | |--------|-------------| | ws/WSController | WebSocket controller with auto-reconnect | | webrtc/PeerConnection | RTCPeerConnection wrapper | | webrtc/sdputils | SDP manipulation utilities |

Fullscreen

| Module | Description | |--------|-------------| | FullscreenController | Fullscreen API controller with fallback | | fullscreen | Cross-browser fullscreen utilities | | fullscreenUtils | Pseudo-fullscreen helpers |

Platform Detection

| Module | Description | |--------|-------------| | platform/getPlatformInfo | Browser/platform detection (ua-parser-js) | | platform/isSafari, isChrome | Browser detection | | platform/isIOS, isAndroid, isMacOS | OS detection | | platform/isMobile | Mobile device detection | | platform/isTouchSupported | Touch support detection | | platform/isMSESupported | Media Source Extensions support | | platform/isEMESupported | Encrypted Media Extensions support | | platform/isAirPlayAvailable | AirPlay availability | | platform/Semver | Semantic version parser |

Responsive

| Module | Description | |--------|-------------| | responsive/MediaQueryListener | Media query change listener | | responsive/MediaQuery | Static media query utilities | | responsive/ViewSize | Viewport size enum and helpers |

Events

| Module | Description | |--------|-------------| | EventEmitterListener | Unified listener for DOM/EventEmitter/EventTarget | | EventListeners | Multi-target event listener manager | | getEventAwaiter | Promise-based event waiting |

DOM

| Module | Description | |--------|-------------| | onDOMReady | Execute callback when DOM is ready | | onPageReady | Execute callback when page is loaded | | getInnerRect | Element inner dimensions | | toLocalPoint | Convert coordinates to local element space | | loadScript | Dynamic script loading with deduplication | | copyToClipboard | Copy text to clipboard |

Files and Blobs

| Module | Description | |--------|-------------| | saveFileAs | Trigger file download | | loadImage | Load image with caching | | blobToDataUrl, dataUrlToBlob | Blob/DataURL conversions | | toBase64, fromBase64 | Unicode-safe base64 encoding | | takeScreenshot | Capture screenshot from CanvasImageSource |

Animation

| Module | Description | |--------|-------------| | createLoop | Interval-based loop with RAF throttling | | createRafLoop | RequestAnimationFrame loop |

Metrics

| Module | Description | |--------|-------------| | metrics/ga/* | Google Analytics helpers | | metrics/yandex/* | Yandex Metrica helpers |

Other

| Module | Description | |--------|-------------| | getRandomID | Random ID via crypto API | | getBrowserLanguage | Browser language detection | | WakeLockController | Screen wake lock | | serviceWorker/ServiceWorkerInstaller | Service worker registration | | iframe/* | Iframe parent-child communication | | viewableTracker | Element visibility tracking |

Usage Examples

FullscreenController

import { FullscreenController } from '@js-toolkit/web-utils/FullscreenController';

const controller = new FullscreenController(document.getElementById('player')!);
await controller.requestFullscreen();
console.log(controller.isFullscreen);

Platform detection

import { isMobile } from '@js-toolkit/web-utils/platform/isMobile';
import { isSafari } from '@js-toolkit/web-utils/platform/isSafari';

if (isMobile()) {
  // mobile-specific logic
}
if (isSafari()) {
  // Safari workaround
}

Event awaiter

import { getEventAwaiter } from '@js-toolkit/web-utils/getEventAwaiter';

const video = document.querySelector('video')!;
await getEventAwaiter(video, 'canplay').wait();
video.play();

Dynamic script loading

import { loadScript } from '@js-toolkit/web-utils/loadScript';

await loadScript('https://cdn.example.com/sdk.js');

Repository

https://github.com/js-toolkit/web-utils