The poster provided an example of poor abstraction. HTML for display, JS for client side logic. Combining them is part of the problem with other popular frameworks.
No, it's the entire point of datastar - that you don't need much JavaScript at all because some simple html attributes do most of it for you, and any extra can either go in-line, or you can also just fallback to separate js scripts if needed.