Unobtrusive JavaScript – What is it?

I came across this concept while reading “JQuery in Action”. I am on chapter 1 and the language and explanations given are excellent. (i.e. once can easily understand)

My understanding for it is:

It is a way to separate the behavior from the structure. Instead of clubbing the event behavior within HTML tags, we can use JQuery selectors to select the HTML element and apply the event behavior through script.

According to the principles of  Unobtrusive JavaScript:

“Any JavaScript expressions or statements embedded in the <body> of
HTML pages, either as attributes of HTML elements (such as onclick) or in script
blocks placed within the body of the page, are considered as correct.”


Unobtrusive JavaScript, though a powerful technique to further add to the
clear separation of responsibilities within a web application, doesn’t come without
its price. Unobtrusive JavaScript not only may increase the amount of script that needs to be written, but also requires some discipline and the application of good coding patterns to the client-side script.

Thoughts on Life, Events and Current Happenings

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.