DEV Community

How to use inline JavaScript with HTML? You definitely like really bad code

Valentine on April 06, 2018

I have made so many mistakes in my short coding lifetime to know never to use the DOM to call javascript methods like this: <button type=...
Collapse
 
gokatz profile image
Gokul Kathirvel

jsx?

Collapse
 
ycmjason profile image
YCM Jason

Haha, yes JSX is horrible code. 😂😂

Collapse
 
chiefoleka profile image
Valentine

Nah.
Vanilla Js in a plain HTML page.

Collapse
 
codefinity profile image
Manav Misra

As a JS instructor, this is one of the biggest pet peeves that I have with student solutions. No matter what I show in the class, there are always a handful of students that try this out because of Googling, I guess.
Then, it's even hard to argue against it b/c with some of our simple assignments, they just say, 'But, it works!' 😞😠

Collapse
 
chiefoleka profile image
Valentine

I totally understand you 🤣🤣
I face this challenge when I'm code reviewing and people are trying to explain away things like this. It can be exhausting but pressing further a little helps them get better and makes my work easy.

You are doing a great job!

Collapse
 
oisin_c profile image
Oisin

Just a quick question about this statement "Inlining does not have any direct performance gains compared to external scripts."

The browser does not have to fetch the script from an external file across a potentially slow connection. This results a faster render??? Or am I missing something?

I agree with all your other points 100%