ryansolid / dom-expressions

A Fine-Grained Runtime for Performant DOM Rendering
MIT License
858 stars 125 forks source link

Shave bytes by removing quotes and spacing from attributes #240

Closed intrnl closed 11 months ago

intrnl commented 1 year ago

This PR attempts to shave more bytes off the template code by removing or replacing the quotes, along with removing the spacing between them when it's next to a quoted attribute value.

The code would eagerly use single quotes when it can't remove the quotes entirely, this is mostly because the template literals would usually be converted into regular string by the transformer/minifier, where they would normally be double quotes. I think by doing this, gzip compression would atleast see that there are more repetitions with (", but that's something that has yet to be tested.

The one thing I haven't done here is to adjust escapeHTML code, as it still assumes that it's being wrapped in a double quote. I wasn't sure how to deal with it, so I just kept it as is but it'd definitely have to be changed I think.

Alternatively we could just drop the code relating to switching between double and single quotes for now.

ryansolid commented 1 year ago

Nice. Yeah we did this with Marko always intended to look into it. I will have to look closer regarding escaping.