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

  • Do either of the answer below answer your question? Jun 12, 2013 at 10:39

2 Answers 2


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.

  • 1
    In jQuery 1.7+ .On() is the recommended and consolidated way of binding events. $("#myId").on("click", function(event){ myFunctionName() });
    – lko
    Jun 5, 2013 at 11:32
  • This is correct. JQuery has changed a lot in a few short years. Jun 5, 2013 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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