Careful With Inline Javascript

less than 1 minute read

An example would be

<button onclick="validate()">Validate</button>

This practice breaks the clean separation that should exist between markup, presentation, and behavior. Also, if scripts load at the bottom of the file, it is possible for a user to interact with the page and trigger an event that attempts to call a script that isn’t loaded yet – causing an error.

Use JQuery or addEventListener

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...