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

@dooboostore/dom-parser

v1.0.2

Published

A lightweight DOM parser for server-side HTML parsing and manipulation with full DOM API support

Readme

@dooboostore/dom-parser

NPM version Build and Test License: MIT

Full Documentation: https://dooboostore-develop.github.io/@dooboostore/dom-parser

A lightweight DOM parser for server-side HTML parsing and manipulation with full DOM API support.


Features

  • ⚡ Server-Side DOM: Complete DOM implementation for Node.js environments
  • 🔍 CSS Selector Support: Full querySelector and querySelectorAll support
  • 📦 Multi-Format: Available as ESM, CJS, and UMD bundles
  • 🛡️ TypeScript: Full TypeScript definitions included
  • 🪶 Zero Dependencies: Lightweight with fast parsing performance
  • 🎯 HTML Templates: Handles complex HTML templates and attributes

Installation

# pnpm
pnpm add @dooboostore/dom-parser

# npm
npm install @dooboostore/dom-parser

# yarn
yarn add @dooboostore/dom-parser

Quick Start

Basic HTML Parsing

import { DomParser } from '@dooboostore/dom-parser';

const html = `
<!DOCTYPE html>
<html>
<head>
    <title>Test Page</title>
</head>
<body>
    <div id="app">
        <h1>Hello World</h1>
        <p class="content">This is a test paragraph.</p>
    </div>
</body>
</html>
`;

const parser = new DomParser(html);
const document = parser.document;

// Use standard DOM APIs
const title = document.querySelector('title');
console.log(title?.textContent); // "Test Page"

const app = document.getElementById('app');
console.log(app?.innerHTML); // Contains the div content

Quick Setup with parseHTML Utility

import { parseHTML } from '@dooboostore/dom-parser';

// Quick way to get window object for SSR
const window = parseHTML(html);
const document = window.document;

// Perfect for setting up global DOM
global.window = window;
global.document = document;

Template Processing

import { DomParser } from '@dooboostore/dom-parser';

// Parse HTML templates with complex attributes
const templateHtml = `
<div class="container">
    <button onclick="handleClick(data)" disabled="false">
        Click Me
    </button>
    <input value="user.name" placeholder="Enter name" />
</div>
`;

const parser = new DomParser(templateHtml);
const document = parser.document;

// Access and modify elements
const button = document.querySelector('button');
console.log(button?.getAttribute('onclick')); // "handleClick(data)"

const input = document.querySelector('input');
input?.setAttribute('value', 'new value');

API Reference

DomParser Class

Constructor

new DomParser(html: string, options?: DomParserOptions)

Creates a new DOM parser instance with the provided HTML string.

Parameters:

  • html: HTML string to parse
  • options: Optional configuration object

DomParserOptions:

interface DomParserOptions {
  href?: string;  // Base URL for the document
}

Properties

  • document: Returns the parsed document object with full DOM API support
  • window: Returns the window object for server-side rendering compatibility

parseHTML Utility Function

Function Signature

parseHTML(html: string, options?: DomParserOptions): Window

A convenient utility function that creates a DomParser instance and returns the window object directly.

Usage:

import { parseHTML } from '@dooboostore/dom-parser';

// Quick setup for SSR
const window = parseHTML('<html><body><h1>Hello</h1></body></html>');
const document = window.document;

// Set up globals
global.window = window;
global.document = document;

// Use DOM APIs immediately
const h1 = document.querySelector('h1');
console.log(h1?.textContent); // "Hello"

Supported DOM APIs

  • document.querySelector() / document.querySelectorAll()
  • document.getElementById() / document.getElementsByClassName()
  • element.innerHTML / element.textContent
  • element.setAttribute() / element.getAttribute()
  • element.appendChild() / element.removeChild()
  • CSS selector parsing with complex expressions
  • Event handling and DOM manipulation

Use Cases

🎯 HTML Processing & Manipulation

import { DomParser } from '@dooboostore/dom-parser';

function processHtml(html: string) {
    const parser = new DomParser(html);
    const document = parser.document;
    
    // Modify the DOM
    const title = document.querySelector('title');
    if (title) {
        title.textContent = 'Processed Title';
    }
    
    // Add meta tags
    const head = document.querySelector('head');
    const meta = document.createElement('meta');
    meta.setAttribute('name', 'description');
    meta.setAttribute('content', 'Processed content');
    head?.appendChild(meta);
    
    return document.documentElement.outerHTML;
}

🔧 Server-Side Rendering (SSR)

import { parseHTML } from '@dooboostore/dom-parser';

// Quick setup with parseHTML utility
const templateHtml = fs.readFileSync('template.html', 'utf8');
const window = parseHTML(templateHtml);

// Set up global DOM for SSR
global.document = window.document;
global.window = window;

// Now your components can use DOM APIs on the server

Alternative with DomParser class:

import { DomParser } from '@dooboostore/dom-parser';

const parser = new DomParser(templateHtml);
global.document = parser.document;
global.window = parser.window;

Learn More

The detailed API documentation, including all supported DOM methods and usage examples, is available on our documentation website.

License

This package is licensed under the MIT License.