3 ms·
Serious question: why is inline JavaScript like that a bad idea? It's easy to find the code that does something, easy to understand what it does and easy to mo
by simonw 3y ago
Serious question: why is inline JavaScript like that a bad idea?
It's easy to find the code that does something, easy to understand what it does and easy to modify it to do something else.
Sure, I wouldn't want to maintain an app with thousands of lines of HTML and JavaScript that works like that, but for a single simple feature on a page that isn't doing anything else I don't see the problem.
- leptons 3y agoIf it is actually a simple bit of inline code, then sure. I mean not more than 2 commands maximum. Any more than that should be inside a <script> tag where it's far easier to write and format the code, debug, abstract, and reason about. The huge amount of code in the example on the HTMJS "blog" is just the worst way to write js code into a webpage because it is not a simple function, it's difficult to read, it won't have syntax highlighting because it's treated as a string.
- alexkutas 3y agoIt's properly highlighted in my IDE, which was actually a surprise.