Skip to content

Instantly share code, notes, and snippets.

@imaginamundo
Created February 20, 2024 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaginamundo/d997ccb195da2ba080f8815940ba0410 to your computer and use it in GitHub Desktop.
Save imaginamundo/d997ccb195da2ba080f8815940ba0410 to your computer and use it in GitHub Desktop.
HTML string test
// Faster
function html() {
const base = arguments[0];
if (!arguments[1]) return base[0];
let html = base[0];
for (let i = 1; i < arguments.length; i++) {
html += arguments[i];
if (base[i]) html += base[i];
}
return html;
}
// Slower
function html(raw, ...variables) {
return String.raw({ raw }, ...variables);
}
@WebReflection
Copy link

@imaginamundo
Copy link
Author

Screenshot 2024-02-23 at 14 04 53
A lot faster :o thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment