Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between obtrusive and unobtrusive javascript

What is the difference between obtrusive and unobtrusive javascript - in plain english. Brevity is appreciated. Short examples are also appreciated.

like image 445
well actually Avatar asked Dec 05 '11 21:12

well actually


People also ask

What is the meaning of unobtrusive JavaScript?

In short, unobtrusive JavaScript is a way of writing JavaScript so that your site visitors are not shut out of your site for one of these reasons—even if your JavaScript is not working correctly for them, they should still be able to use your site, albeit at a more basic level.

What is the meaning of unobtrusive JavaScript explain us by any practical example?

Unobtrusive JavaScript is a general approach to the use of client-side JavaScript in web pages so that if JavaScript features are partially or fully absent in a user's web browser, then the user notices as little as possible any lack of the web page's JavaScript functionality.

What is the meaning of unobtrusive JavaScript in MVC?

Unobtrusive JavaScript is a general term that conveys a general set of guidelines or margins to the term REST. REST is nothing but the Representational State Transfer. We can explain Unobtrusive JavaScript as- it is not your particular JavaScript code that you generally use in your markup page.


1 Answers

No javascript in the markup is unobtrusive:

Obtrusive:

<div onclick="alert('obstrusive')">Information</div> 

Unobtrusive:

<div id="informationHeader">Information</div> 
window.informationHeader.addEventListener('click', (e) => alert('unobstrusive')) 
like image 113
Joe Avatar answered Oct 05 '22 20:10

Joe