Skip to content

Instantly share code, notes, and snippets.

View elie-g's full-sized avatar
🎯
Focusing

Elie Grenon elie-g

🎯
Focusing
View GitHub Profile
@elie-g
elie-g / README.md
Last active October 30, 2021 10:04 — forked from jonathantneal/README.md
createElement.js // a 300 byte DOM Element creator

createElement.js

createElement.js lets document.createElement use CSS selectors.

This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.

Usage

document.createElement(); // generates <div />