HEEx attribute value in quotes send less data than values in braces

The websocket diff update for data-quotes={"#{@value}"} sends '123'.

The websocket diff update for data-braces={@value} sends ' data-braces="123"'.

value = "123"
~H"""
<div data-quotes={"#{@value}"} data-braces={@value} />
"""

Is there a documentation about optimizations like this?

I would guess that is a way to let you nil the value and not get the attribute?

Empty attribute string vs no attribute set.

3 Likes

This also isn’t actually an optimization. Boolean attributes even with empty “value” are still considered to be true or set: Boolean attribute (HTML) - MDN Web Docs Glossary: Definitions of Web-related terms | MDN

The only way to make them be false is by not rendering the attribute at all.

2 Likes