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

assjs-v2

v1.0.8

Published

A lightweight JavaScript ASS subtitle renderer

Readme

ASS.js (v2 by Shahzad)

GitHub Action Codecov License File size

Online Demo ASS Specs (zh-Hans) ass-compiler


ASS.js renders ASS subtitles on HTML5 videos using DOM elements with almost full ASS feature support.

It’s lightweight, accurate, and ideal for the web, being around 60× smaller than WebAssembly-based solutions:

| | Solution | Size | | - | - | - | | ASS.js | DOM | | | JavascriptSubtitlesOctopus | WebAssembly | | | JASSUB | WebAssembly | |

WebAssembly solutions often require large fallback fonts to prevent CJK text from rendering as tofu.
ASS.js uses the browser’s built-in font fallback, so it works out of the box.


📦 Installation

NPM Version jsDelivr unpkg

npm install assjs-v2

Importing

<script type="module">
  import ASS from '/path/to/assjs-v2/dist/ass.min.js';
</script>

or via global script:

<script src="/path/to/assjs-v2/dist/ass.global.min.js"></script>
<script>
  console.log(window.ASS);
</script>

🧩 Usage

<div id="player">
  <video id="video" src="./example.mp4"></video>
  <div id="ass-container"></div>
</div>
import ASS from 'assjs-v2';

const content = await fetch('/path/to/example.ass').then(res => res.text());

const ass = new ASS(content, document.querySelector('#video'), {
  container: document.querySelector('#ass-container'),
});

When initialized, ASS appends subtitle elements inside the container and automatically syncs the rendering area with the video.

Make sure your container overlaps the video properly:

<div id="player" style="position: relative;">
  <video id="video" src="./example.mp4" style="position: absolute; top: 0; left: 0;"></video>
  <div id="ass-container" style="position: absolute; top: 0; left: 0;"></div>
</div>

If using the native fullscreen button, only the <video> goes fullscreen, hiding subtitles. Instead, call:

document.querySelector('#player').requestFullscreen();

⚙️ API Reference

Initialization

const ass = new ASS(content, video, {
  // Subtitles display inside this container
  container: document.getElementById('my-container'),

  // Controls how subtitle scaling is calculated
  resampling: 'video_width',
});

Methods

ass.show();     // Show subtitles
ass.hide();     // Hide subtitles
ass.destroy();  // Destroy instance

Delay

ass.delay = 5;   // Subtitles appear 5s later
ass.delay = -3;  // Subtitles appear 3s earlier

📐 Resampling

When the ASS script resolution (PlayResX / PlayResY) does not match the video resolution, the resampling option controls how scaling behaves.

Drawings and clips always follow the original script resolution.

| Value | Description | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | video_width | Scale based on video width. Example: 640×480 → scaled to 640×360, scale = 1280 / 640 = 2. | | video_height (default) | Scale based on video height. Example: 640×480 → scaled to 853×480, scale = 720 / 480 = 1.5. | | script_width | Keep script resolution but scale using script width. May cause vertical cropping. | | script_height | Keep script resolution but scale using script height. Centered vertically. | | container | 🆕 (New in v2) — Script resolution automatically matches the container size. Ideal for responsive overlays or custom players. |

ass.resampling = 'container';

🌐 Browser Compatibility

| Feature | Web API | Chrome | Firefox | Safari | | --------------------------- | ------------------------------------------------------------------------------------------------------------- | ------ | ------- | ------ | | Auto resize | ResizeObserver | 64 | 69 | 13.1 | | \[i]clip | clip-path / path() | 88 | 97 | 13.1 | | Animations (\t) | registerProperty() | 78 | 128 | 16.4 | | accel in \t | linear() | 113 | 112 | 17.2 | | \q0 | text-wrap: balance | 114 | 121 | 17.5 | | BorderStyle=3 with \bord0 | @container | 111 | - | 18.0 | | \blur with \bord0 | round() | 125 | 118 | 15.4 |


🧠 Notes

  • assjs-v2 introduces the new container resampling mode for responsive, container-based rendering.
  • Original library by @weizhenye
  • Maintained and improved by @code-with-shahzad


💼 Connect with Me

I’m always open to collaborations and discussions about open-source projects, AI, and frontend innovation.

LinkedIn GitHub Email


🪪 License

MIT © Shahzad Siddique