Skip to content

Instantly share code, notes, and snippets.

@MarekZeman91
Last active February 19, 2023 02:58
Show Gist options
  • Save MarekZeman91/b74d31eda1001f8380109ab5c1606108 to your computer and use it in GitHub Desktop.
Save MarekZeman91/b74d31eda1001f8380109ab5c1606108 to your computer and use it in GitHub Desktop.
One of the laziest EL implementations, but with cache
export const el = (nodeName, props = {}, children = []) => {
const $el = (el.cache[nodeName] || (
el.cache[nodeName] = document.createElement(nodeName)
)).cloneNode(true);
Object.assign($el, props).append(...children);
return $el;
};
el.cache = {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment