happy-dom
Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.
Last updated a year ago by davidortner .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install happy-dom 
SYNC missed versions from official npm registry.

Happy DOM Logo

About

Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.

The goal of Happy DOM is to emulate enough of a web browser to be useful for testing, scraping web sites and server-side rendering.

Happy DOM focuses heavily on performance and can be used as an alternative to JSDOM.

DOM Features

  • Custom Elements (Web Components)

  • Shadow Root (Shadow DOM)

  • Declarative Shadow DOM

  • Mutation Observer

  • Tree Walker

  • Fetch

And much more..

Works With

Module Systems

Installation

npm install happy-dom

Usage

A simple example of how you can use Happy DOM.

import { Window } from 'happy-dom';

const window = new Window({
	url: 'https://localhost:8080',
	width: 1024,
	height: 768
});
const document = window.document;

document.body.innerHTML = '<div class="container"></div>';

const container = document.querySelector('.container');
const button = document.createElement('button');

container.appendChild(button);

// Outputs "<div class="container"><button></button></div>"
console.log(document.body.innerHTML);

Documentation

Read more about how to use Happy DOM in our Wiki.

Performance

Operation JSDOM Happy DOM
Import / Require 333 ms 45 ms
Parse HTML 256 ms 26 ms
Serialize HTML 65 ms 8 ms
Render custom element 214 ms 19 ms
querySelectorAll('tagname') 4.9 ms 0.7 ms
querySelectorAll('.class') 6.4 ms 3.7 ms
querySelectorAll('[attribute]') 4.0 ms 1.7 ms
querySelectorAll('[class~="name"]') 5.5 ms 2.9 ms
querySelectorAll(':nth-child(2n+1)') 10.4 ms 3.8 ms

See how the test was done here

Jest

Happy DOM provide with a package called @happy-dom/jest-environment that makes it possible to use Happy DOM with Jest.

Vitest

Vitest supports Happy DOM out of the box.

Global Registration

Happy DOM provide with a package called @happy-dom/global-registrator that can register Happy DOM globally. It makes it possible to use Happy DOM for testing in a Node environment.

Sponsors

RTVision

Current Tags

  • 12.1.2                                ...           latest (a year ago)

438 Versions

  • 12.1.2                                ...           a year ago
  • 12.1.1                                ...           a year ago
  • 12.1.0                                ...           a year ago
  • 12.0.1                                ...           a year ago
  • 12.0.0                                ...           a year ago
  • 11.2.0                                ...           a year ago
  • 11.1.2                                ...           a year ago
  • 11.1.1                                ...           a year ago
  • 11.1.0                                ...           a year ago
  • 11.0.6                                ...           a year ago
  • 11.0.5                                ...           a year ago
  • 11.0.4                                ...           a year ago
  • 11.0.3                                ...           a year ago
  • 11.0.2                                ...           a year ago
  • 11.0.1                                ...           a year ago
  • 11.0.0                                ...           a year ago
  • 10.11.2                                ...           a year ago
  • 10.11.1                                ...           a year ago
  • 10.11.0                                ...           a year ago
  • 10.10.4                                ...           a year ago
  • 10.10.3                                ...           a year ago
  • 10.10.2                                ...           a year ago
  • 10.10.1                                ...           a year ago
  • 10.10.0                                ...           a year ago
  • 10.9.0                                ...           a year ago
  • 10.8.1                                ...           a year ago
  • 10.8.0                                ...           a year ago
  • 10.7.0                                ...           a year ago
  • 10.6.3                                ...           a year ago
  • 10.6.2                                ...           a year ago
  • 10.6.1                                ...           a year ago
  • 10.6.0                                ...           a year ago
  • 10.5.3                                ...           a year ago
  • 10.5.2                                ...           a year ago
  • 10.5.1                                ...           a year ago
  • 10.5.0                                ...           a year ago
  • 10.4.0                                ...           a year ago
  • 10.3.2                                ...           a year ago
  • 10.3.1                                ...           a year ago
  • 10.3.0                                ...           a year ago
  • 10.2.0                                ...           a year ago
  • 10.1.1                                ...           a year ago
  • 10.1.0                                ...           a year ago
  • 10.0.7                                ...           a year ago
  • 10.0.6                                ...           a year ago
  • 10.0.5                                ...           a year ago
  • 10.0.4                                ...           a year ago
  • 10.0.3                                ...           a year ago
  • 10.0.2                                ...           a year ago
  • 10.0.1                                ...           a year ago
  • 10.0.0                                ...           a year ago
  • 9.20.3                                ...           2 years ago
  • 9.20.2                                ...           2 years ago
  • 9.20.1                                ...           2 years ago
  • 9.20.0                                ...           2 years ago
  • 9.19.2                                ...           2 years ago
  • 9.19.1                                ...           2 years ago
  • 9.19.0                                ...           2 years ago
  • 9.18.3                                ...           2 years ago
  • 9.18.2                                ...           2 years ago
  • 9.18.1                                ...           2 years ago
  • 9.18.0                                ...           2 years ago
  • 9.17.0                                ...           2 years ago
  • 9.16.0                                ...           2 years ago
  • 9.15.0                                ...           2 years ago
  • 9.14.0                                ...           2 years ago
  • 9.13.1                                ...           2 years ago
  • 9.13.0                                ...           2 years ago
  • 9.12.0                                ...           2 years ago
  • 9.11.0                                ...           2 years ago
  • 9.10.9                                ...           2 years ago
  • 9.10.8                                ...           2 years ago
  • 9.10.7                                ...           2 years ago
  • 9.10.6                                ...           2 years ago
  • 9.10.5                                ...           2 years ago
  • 9.10.4                                ...           2 years ago
  • 9.10.3                                ...           2 years ago
  • 9.10.2                                ...           2 years ago
  • 9.10.1                                ...           2 years ago
  • 9.10.0                                ...           2 years ago
  • 9.9.2                                ...           2 years ago
  • 9.9.1                                ...           2 years ago
  • 9.9.0                                ...           2 years ago
  • 9.8.4                                ...           2 years ago
  • 9.8.3                                ...           2 years ago
  • 9.8.2                                ...           2 years ago
  • 9.8.1                                ...           2 years ago
  • 9.8.0                                ...           2 years ago
  • 9.7.1                                ...           2 years ago
  • 9.7.0                                ...           2 years ago
  • 9.6.1                                ...           2 years ago
  • 9.6.0                                ...           2 years ago
  • 9.5.1                                ...           2 years ago
  • 9.5.0                                ...           2 years ago
  • 9.4.0                                ...           2 years ago
  • 9.3.2                                ...           2 years ago
  • 9.3.1                                ...           2 years ago
  • 9.3.0                                ...           2 years ago
  • 9.2.1                                ...           2 years ago
  • 9.2.0                                ...           2 years ago
  • 9.1.10                                ...           2 years ago
  • 9.1.9                                ...           2 years ago
  • 9.1.8                                ...           2 years ago
  • 9.1.7                                ...           2 years ago
  • 9.1.6                                ...           2 years ago
  • 9.1.5                                ...           2 years ago
  • 9.1.4                                ...           2 years ago
  • 9.1.3                                ...           2 years ago
  • 9.1.0                                ...           2 years ago
  • 9.0.1                                ...           2 years ago
  • 9.0.0                                ...           2 years ago
  • 8.9.0                                ...           2 years ago
  • 8.8.0                                ...           2 years ago
  • 8.7.6                                ...           2 years ago
  • 8.7.5                                ...           2 years ago
  • 8.7.4                                ...           2 years ago
  • 8.7.3                                ...           2 years ago
  • 8.7.2                                ...           2 years ago
  • 8.7.1                                ...           2 years ago
  • 8.7.0                                ...           2 years ago
  • 8.6.0                                ...           2 years ago
  • 8.5.0                                ...           2 years ago
  • 8.4.4                                ...           2 years ago
  • 8.4.3                                ...           2 years ago
  • 8.4.2                                ...           2 years ago
  • 8.4.1                                ...           2 years ago
  • 8.4.0                                ...           2 years ago
  • 8.3.2                                ...           2 years ago
  • 8.3.1                                ...           2 years ago
  • 8.3.0                                ...           2 years ago
  • 8.2.6                                ...           2 years ago
  • 8.2.5                                ...           2 years ago
  • 8.2.4                                ...           2 years ago
  • 8.2.3                                ...           2 years ago
  • 8.2.2                                ...           2 years ago
  • 8.2.1                                ...           2 years ago
  • 8.2.0                                ...           2 years ago
  • 8.1.5                                ...           2 years ago
  • 8.1.4                                ...           2 years ago
  • 8.1.3                                ...           2 years ago
  • 8.1.2                                ...           2 years ago
  • 8.1.1                                ...           2 years ago
  • 8.1.0                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.8.1                                ...           2 years ago
  • 7.8.0                                ...           2 years ago
  • 7.7.2                                ...           2 years ago
  • 7.7.1                                ...           2 years ago
  • 7.7.0                                ...           2 years ago
  • 7.6.7                                ...           2 years ago
  • 7.6.6                                ...           2 years ago
  • 7.6.5                                ...           2 years ago
  • 7.6.4                                ...           2 years ago
  • 7.6.3                                ...           2 years ago
  • 7.6.2                                ...           2 years ago
  • 7.6.1                                ...           2 years ago
  • 7.6.0                                ...           2 years ago
  • 7.5.14                                ...           2 years ago
  • 7.5.13                                ...           2 years ago
  • 7.5.12                                ...           2 years ago
  • 7.5.11                                ...           2 years ago
  • 7.5.10                                ...           2 years ago
  • 7.5.9                                ...           2 years ago
  • 7.5.8                                ...           2 years ago
  • 7.5.7                                ...           2 years ago
  • 7.5.6                                ...           2 years ago
  • 7.5.5                                ...           2 years ago
  • 7.5.4                                ...           2 years ago
  • 7.5.3                                ...           2 years ago
  • 7.5.2                                ...           2 years ago
  • 7.5.1                                ...           2 years ago
  • 7.5.0                                ...           2 years ago
  • 7.4.0                                ...           2 years ago
  • 7.3.0                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.1                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.6                                ...           2 years ago
  • 7.0.5                                ...           2 years ago
  • 7.0.4                                ...           2 years ago
  • 7.0.3                                ...           2 years ago
  • 7.0.2                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 6.0.4                                ...           2 years ago
  • 6.0.3                                ...           2 years ago
  • 6.0.2                                ...           2 years ago
  • 6.0.1                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.4.0                                ...           2 years ago
  • 5.3.4                                ...           2 years ago
  • 5.3.3                                ...           2 years ago
  • 5.3.2                                ...           2 years ago
  • 5.3.1                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.2.2                                ...           3 years ago
  • 3.2.1                                ...           3 years ago
  • 3.2.0                                ...           3 years ago
  • 3.1.1                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.55.0                                ...           3 years ago
  • 2.54.0                                ...           3 years ago
  • 2.53.1                                ...           3 years ago
  • 2.53.0                                ...           3 years ago
  • 2.52.0                                ...           3 years ago
  • 2.51.1                                ...           3 years ago
  • 2.51.0                                ...           3 years ago
  • 2.50.0                                ...           3 years ago
  • 2.49.2                                ...           3 years ago
  • 2.49.1                                ...           3 years ago
  • 2.49.0                                ...           3 years ago
  • 2.48.0                                ...           3 years ago
  • 2.47.3                                ...           3 years ago
  • 2.47.2                                ...           3 years ago
  • 2.47.1                                ...           3 years ago
  • 2.47.0                                ...           3 years ago
  • 2.46.3                                ...           3 years ago
  • 2.46.2                                ...           3 years ago
  • 2.46.1                                ...           3 years ago
  • 2.46.0                                ...           3 years ago
  • 2.45.1                                ...           3 years ago
  • 2.45.0                                ...           3 years ago
  • 2.43.1                                ...           3 years ago
  • 2.43.0                                ...           3 years ago
  • 2.42.0                                ...           3 years ago
  • 2.41.0                                ...           3 years ago
  • 2.40.3                                ...           3 years ago
  • 2.40.2                                ...           3 years ago
  • 2.40.1                                ...           3 years ago
  • 2.40.0                                ...           3 years ago
  • 2.39.1                                ...           3 years ago
  • 2.39.0                                ...           3 years ago
  • 2.38.0                                ...           3 years ago
  • 2.37.0                                ...           3 years ago
  • 2.36.0                                ...           3 years ago
  • 2.35.0                                ...           3 years ago
  • 2.34.0                                ...           3 years ago
  • 2.33.1                                ...           3 years ago
  • 2.33.0                                ...           3 years ago
  • 2.32.0                                ...           3 years ago
  • 2.31.1                                ...           3 years ago
  • 2.31.0                                ...           3 years ago
  • 2.30.1                                ...           3 years ago
  • 2.30.0                                ...           3 years ago
  • 2.29.0                                ...           3 years ago
  • 2.28.0                                ...           3 years ago
  • 2.27.3                                ...           3 years ago
  • 2.27.2                                ...           3 years ago
  • 2.27.0                                ...           3 years ago
  • 2.26.0                                ...           3 years ago
  • 2.25.2                                ...           3 years ago
  • 2.25.1                                ...           3 years ago
  • 2.25.0                                ...           3 years ago
  • 2.24.5                                ...           3 years ago
  • 2.24.4                                ...           3 years ago
  • 2.24.3                                ...           3 years ago
  • 2.24.2                                ...           3 years ago
  • 2.24.1                                ...           3 years ago
  • 2.24.0                                ...           3 years ago
  • 2.23.0                                ...           3 years ago
  • 2.22.1                                ...           3 years ago
  • 2.22.0                                ...           3 years ago
  • 2.21.0                                ...           3 years ago
  • 2.20.1                                ...           4 years ago
  • 2.20.0                                ...           4 years ago
  • 2.19.3                                ...           4 years ago
  • 2.19.2                                ...           4 years ago
  • 2.19.1                                ...           4 years ago
  • 2.19.0                                ...           4 years ago
  • 2.18.1                                ...           4 years ago
  • 2.18.0                                ...           4 years ago
  • 2.17.1                                ...           4 years ago
  • 2.17.0                                ...           4 years ago
  • 2.16.3                                ...           4 years ago
  • 2.16.2                                ...           4 years ago
  • 2.16.1                                ...           4 years ago
  • 2.16.0                                ...           4 years ago
  • 2.15.0                                ...           4 years ago
  • 2.14.0                                ...           4 years ago
  • 2.13.0                                ...           4 years ago
  • 2.12.0                                ...           4 years ago
  • 2.11.2                                ...           4 years ago
  • 2.11.1                                ...           4 years ago
  • 2.11.0                                ...           4 years ago
  • 2.10.1                                ...           4 years ago
  • 2.10.0                                ...           4 years ago
  • 2.9.0                                ...           4 years ago
  • 2.8.0                                ...           4 years ago
  • 2.7.0                                ...           4 years ago
  • 2.6.3                                ...           4 years ago
  • 2.6.2                                ...           4 years ago
  • 2.6.1                                ...           4 years ago
  • 2.6.0                                ...           4 years ago
  • 2.5.1                                ...           4 years ago
  • 2.5.0                                ...           4 years ago
  • 2.4.1                                ...           4 years ago
  • 2.4.0                                ...           4 years ago
  • 2.3.0                                ...           4 years ago
  • 2.2.0                                ...           4 years ago
  • 2.1.6                                ...           4 years ago
  • 2.1.5                                ...           4 years ago
  • 2.1.4                                ...           4 years ago
  • 2.1.3                                ...           4 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.18.2                                ...           4 years ago
  • 1.18.1                                ...           4 years ago
  • 1.18.0                                ...           4 years ago
  • 1.17.0                                ...           4 years ago
  • 1.16.1                                ...           4 years ago
  • 1.16.0                                ...           4 years ago
  • 1.15.0                                ...           4 years ago
  • 1.14.1                                ...           4 years ago
  • 1.14.0                                ...           4 years ago
  • 1.13.0                                ...           4 years ago
  • 1.12.0                                ...           4 years ago
  • 1.11.5                                ...           4 years ago
  • 1.11.4                                ...           4 years ago
  • 1.11.3                                ...           4 years ago
  • 1.11.2                                ...           4 years ago
  • 1.11.1                                ...           4 years ago
  • 1.11.0                                ...           4 years ago
  • 1.10.4                                ...           4 years ago
  • 1.10.3                                ...           4 years ago
  • 1.10.2                                ...           4 years ago
  • 1.10.1                                ...           4 years ago
  • 1.10.0                                ...           4 years ago
  • 1.9.0                                ...           4 years ago
  • 1.8.0                                ...           4 years ago
  • 1.7.2                                ...           4 years ago
  • 1.7.1                                ...           4 years ago
  • 1.7.0                                ...           4 years ago
  • 1.6.4                                ...           4 years ago
  • 1.6.3                                ...           4 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.1                                ...           4 years ago
  • 1.6.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.1                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.15                                ...           4 years ago
  • 1.1.14                                ...           4 years ago
  • 1.1.13                                ...           4 years ago
  • 1.1.12                                ...           4 years ago
  • 1.1.11                                ...           4 years ago
  • 1.1.10                                ...           4 years ago
  • 1.1.9                                ...           4 years ago
  • 1.1.8                                ...           4 years ago
  • 1.1.7                                ...           4 years ago
  • 1.1.6                                ...           4 years ago
  • 1.1.5                                ...           4 years ago
  • 1.1.4                                ...           4 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.14.1                                ...           5 years ago
  • 0.14.0                                ...           5 years ago
  • 0.13.0                                ...           5 years ago
  • 0.12.1                                ...           5 years ago
  • 0.12.0                                ...           5 years ago
  • 0.11.1                                ...           5 years ago
  • 0.11.0                                ...           5 years ago
  • 0.10.8                                ...           5 years ago
  • 0.10.7                                ...           5 years ago
  • 0.10.6                                ...           5 years ago
  • 0.10.5                                ...           5 years ago
  • 0.10.4                                ...           5 years ago
  • 0.10.3                                ...           5 years ago
  • 0.10.2                                ...           5 years ago
  • 0.10.1                                ...           5 years ago
  • 0.10.0                                ...           5 years ago
  • 0.9.0                                ...           5 years ago
  • 0.8.6                                ...           5 years ago
  • 0.8.5                                ...           5 years ago
  • 0.8.4                                ...           5 years ago
  • 0.8.3                                ...           5 years ago
  • 0.8.2                                ...           5 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.4                                ...           5 years ago
  • 0.6.3                                ...           5 years ago
  • 0.6.2                                ...           5 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.1                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.11                                ...           5 years ago
  • 0.4.9                                ...           5 years ago
  • 0.4.8                                ...           5 years ago
  • 0.4.7                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.4                                ...           5 years ago
  • 0.4.3                                ...           5 years ago
  • 0.4.2                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.15                                ...           5 years ago
  • 0.2.14                                ...           5 years ago
  • 0.2.13                                ...           5 years ago
  • 0.2.12                                ...           5 years ago
  • 0.2.11                                ...           5 years ago
  • 0.2.10                                ...           5 years ago
  • 0.2.9                                ...           5 years ago
  • 0.2.8                                ...           5 years ago
  • 0.2.7                                ...           5 years ago
  • 0.2.6                                ...           5 years ago
  • 0.2.5                                ...           5 years ago
  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |