As SVG is XML, you can use XML style comments:
<!--
comment
-->
For example:
<g onclick = "setScale(1)">
<rect id = "scale1" x = "120" y = "10" width = "30" height = "30"
fill = "#ffc" stroke = "black"/>
<!--
this text describes middle rectangle
-->
<text x = "135" y = "30" text-anchor = "middle">M</text>
</g>
Or you can exclude some part of code:
<!--
this group is disabled for testing
<g onclick = "setScale(1)">
<rect id = "scale1" x = "120" y = "10" width = "30" height = "30"
fill = "#ffc" stroke = "black"/>
<text x = "135" y = "30" text-anchor = "middle">M</text>
</g>
-->