
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
universal-dompurify
Advanced tools
š Use DOMPurify for some context by conditional exports
npm i universal-dompurify
Conditional exports apply the appropriate DOMPurify file at each run.
import DOMPurify from 'universal-dompurify'
const cleaned = DOMPurify.sanitize(/* ... */)
condition | resolve |
---|---|
browser | DOMPurify |
default | DOMPurify + JSDOM |
worker | DOMPurify + JSDOM + (require: your external node polyfills) |
[!TIP] It is generally not recommended to use JSDOM with the restricted Edge runtime.
See also @jill64/universal-sanitizer for a more lightweight alternative.
Reduces bundle size by omitting rendering on the server.
/** @type {DOMPurify | null} */
import DOMPurify from 'universal-dompurify/browser-only'
const cleaned = DOMPurify?.sanitize?.(/* ... */) ?? 'server-fallback-value'
condition | resolve |
---|---|
browser | DOMPurify |
default | null |
worker | null |
FAQs
š Use DOMPurify for some context by conditional exports
We found that universal-dompurify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.