Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Unobtrusive JavaScript avoids injecting inline JavaScript into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries

what really is it ?( i am really trying to go deeper in the above article) can some one explain in simpler words

share|improve this question
Do either of the answer below answer your question? – gingerbreadboy Jun 12 '13 at 10:39

instead of having onclick events defined on your elements like so

<a href="#" id="myId" onClick="myFunctionName()">Say Hi</a>

you push the binding out into you jscript file so your html looks more like...

<a href="#" id="myId" >Say Hi</a>

And in your code file... ( jquery for the example)


See this on Jquery...

This applies to everything, not just "click" events.

share|improve this answer
In jQuery 1.7+ .On() is the recommended and consolidated way of binding events. $("#myId").on("click", function(event){ myFunctionName() }); – lko Jun 5 '13 at 11:32
This is correct. JQuery has changed a lot in a few short years. – gingerbreadboy Jun 5 '13 at 11:47

I get the impression from the things I've been reading and seeing is that it means more JS will be pulled out into external library files and not put inline in the HTML page.

I came across a good article by Brad Wilson that gives a good overview of Unobtrusive Javascript.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.