Is it bad practice to use inline event handlers in HTML?

Sharikul Islam picture Sharikul Islam · Apr 3, 2013 · Viewed 8.4k times · Source

Is it bad to use inline JavaScript event handlers, or is that fine?

On the page I plan to use it on, I'm only going to use an event handler once, so is it acceptable to use an inline event handler in this case, or shall I write the code for the event handler within <script> tags?

Answer

Jason Yaraghi picture Jason Yaraghi · Apr 3, 2013

Its bad practice if your concern is readability in your mark-up and maintenance, especially on a larger scale it can get quite messy - also keep in mind the inline JS will never be cached like an external js file would so you do suffer a bit in regards to performance especially if you abuse it

Read this article for more insight: http://robertnyman.com/2008/11/20/why-inline-css-and-javascript-code-is-such-a-bad-thing/