raf

A requestAnimationFrame polyfill that provides a consistent animation-frame API across Node.js and browsers.

Library
npm
v3.4.1
738stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
66/100Good
Architecture60
Code Quality55
Innovation65
Learning Curve85

raf is a small polyfill for requestAnimationFrame and cancelAnimationFrame that works in both Node.js and browser environments. It first tries the native (or vendor-prefixed) implementation and falls back to a setTimeout-based queue timed to roughly 60fps when neither is available, using the performance-now package for consistent timing.

The library exposes the same raf(callback) / raf.cancel(handle) calling convention as the native browser API, plus a raf.polyfill([object]) helper that patches requestAnimationFrame/cancelAnimationFrame directly onto window or a given object. It is widely depended upon transitively by animation and UI libraries that need a dependable frame-scheduling primitive without caring whether the runtime is a browser or Node.js.

What You Get

  • A raf(callback) function matching the native requestAnimationFrame signature
  • raf.cancel(handle) to cancel a queued callback
  • raf.polyfill([object]) to patch requestAnimationFrame/cancelAnimationFrame onto window or a custom object
  • Automatic vendor-prefix detection (moz, webkit) before falling back to a manual queue

Common Use Cases

  • Providing a consistent animation-frame primitive for libraries that must run in both Node.js (SSR/testing) and browser contexts
  • Polyfilling requestAnimationFrame in older or non-standard browser environments
  • Driving custom animation loops in UI libraries without depending on a full animation framework
  • Server-side rendering or headless-testing setups where window.requestAnimationFrame doesn’t exist

Under The Hood

Architecture - The whole package is a single index.js module: it detects a native (or vendor-prefixed) requestAnimationFrame/cancelAnimationFrame on window/global, and if neither is found, builds a small closure-based fallback consisting of a queue array, a last timestamp, and an incrementing id handle counter. The fallback schedules a single setTimeout per batch (timed against performance-now) that drains the whole queue, invoking each non-cancelled callback and re-arming for the next 60fps tick. polyfill.js and window.js are thin entry variants that call .polyfill() immediately or target a specific object. Tech Stack - Plain, dependency-light JavaScript (ES5-style, no build step) with a single runtime dependency on performance-now for consistent high-resolution timing across environments; no TypeScript, no bundler config, and the published package is the raw source. Code Quality - test.js exercises the queueing/cancellation behavior with a simple assertion-style test file; the code favors small, readable functions with minimal branching, though there is no formal type layer and error handling around user callbacks is limited to wrapping invocation in try/catch and rethrowing async via setTimeout. API Design - The API mirrors the native requestAnimationFrame/cancelAnimationFrame contract exactly (raf(callback) returns a handle, raf.cancel(handle) cancels it), which makes it a true drop-in replacement requiring zero learning curve for anyone already familiar with the browser API, plus one additional raf.polyfill() convenience method for global patching.

Used by 5 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
89%
Other

anytype-ts

Knowledge Management · Note Taking · Collaboration

8,665

A local-first, end-to-end encrypted knowledge OS that lets you build notes, tasks, wikis, and entire apps — with your data stored offline and synced peer-to-peer.

View details
88
Repo Health
78
Technical
67
Dependency
Built with
TypeScript89%
Updated yesterday
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,041

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
65
Dependency
Built with
JavaScript99%
Updated 6 days ago
Clojure
54%
Other

Metabase

Analytics

48,828

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
65
Dependency
Built with
Clojure54%
TypeScript40%
Updated today
TypeScript
99%
MIT

Sanity

CMS

6,279

Open-source headless CMS with a fully customizable React Studio, real-time collaborative editing, structured content modeling, and GROQ query language

View details
92
Repo Health
90
Technical
72
Dependency
Built with
TypeScript99%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search