When you need this, you need it. When you don't, prefer static html.
Keep in mind, the folks who write developer documentation for things like this have had their head in this problem space for a long time. So there's less explanation of the "what" and "why", and examples tend to be more oriented to the "how".
Right, I said "static html" not meaning to imply that it was the same thing. I wouldn't consider "straight html" to include script code, but I think it's a valid criticism of my advice that it is oversimplistic.