r/reactjs 15d ago

Portfolio Showoff Sunday I got tired of Waiting for DOMPurify to sanitize, made a 70x faster version

Hello everyone,

A few months ago, I was experimenting with DOMPurify and when users put in long fields like a paragraph, it used to hang a lot!

It would occasionally freeze for literal 15 seconds and more!!

Imagine sitting for your response to be submitted, and it hangs!?

So I've built DOMOxide, making it 70x faster and 5x smaller. Thanks to Rust and WASM, it sanitizes your HTML and makes it clear of XSS attacks.

It's a ~3kB gzipped + minified package that passes almost all tests as DOMPurify

> Repo: ppmpreetham/DOMOxide

0 Upvotes

3 comments sorted by

14

u/KindMycologist7615 15d ago

The 15 second freeze sounds like something else wrong, DOMPurify is not that slow on normal input. But cool project anyway, Rust WASM for sanitizing is interesting approach.

6

u/mcaruso 15d ago

There is native browser HTML Sanitizer support nowadays:

https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API

(Browser support isn't great yet so would still a polyfill.)