To create custom components, we can use custom elements. Even if we like me don't use custom components, custom elements can be used anyway, as markup. I use Vue at the moment.
Instead of this:
<div class="row>
I could use this:
<t-row>
It's a bit shorter and with a big template, it would save quite a bit of code size.
I have a few questions about this approach:
ignoredElements
to ignore elements like [/^t-/]
. How will that affect performance?All this boils down to a single question...
Should I use custom elements as markup if I feel it could save me time and improve readability? Explain why.
An answer to question #2, arguments why not to do it:
You have to take GZip into account
Yes <div class="row">
is more to type
but might actually create a smaller file delivered to the browser
because you used it so much and GZip encoded that 17 bytes to a few BITS.
IMHO a developer should think about delivering the best code to his/her successor,
not about optimization he/she is the only one to understand.
The first response to <t-row>
will be What the Fuk is going on here
not Oh this is readable.
Another IMHO
Do not use t-
just because you want to create a custom element,
namespaces should have meaning.