55 ms·
Am I the only one who doesn't add random attributes to the existing HTML elements? I use the dataset `data-` attributes for that. You can go nuts with custom el
by skerit 4y ago
Am I the only one who doesn't add random attributes to the existing HTML elements? I use the dataset `data-` attributes for that.
You can go nuts with custom elements though.
- blowski 4y agoWhat practical difference does it make?
- rglover 4y agoMaintainability and browser compatibility (less of an issue these days). If you use a non-standard attribute and hand your code off to someone else, they likely won't catch it and can introduce bugs.
- blowski 4y agoRegarding the bugs, what makes it more of a problem in HTML attributes than with any other code?
- rglover 4y agoNothing makes it more of a problem. Same as any other code. Just the idea of introducing non-standard things (especially if used inconsistently) increases the likelihood that things will break and be harder to fix. For example, if someone binds an event listener to an element in two different places with something like clicker="button" in one place and then uses data-clickable="true" in another place, it can introduce confusion. Not only does the original developer have to remember all of their custom attributes but so does anybody else who comes on to the project.