Unobtrusive JavaScript | Targetprocess - Enterprise Agility Solution

One of the latest trends in client-side development is the unobtrusive JavaScript. This trend is very good, since it extends separation of concerns. Several years ago the same happened with CSS. Web designers used FONT tag, BGCOLOR attribute and other visual style representation HTML elements extensively. Pages were bloated with style elements and style change was a real pain.

CSS changed that completely. It separated document structure from presentation and modern web designers likely do not know what FONT tag was designed for. While CSS separates presentation from document structure, unobtrusive JavaScript separates behavior from the structure.

There are quite many frameworks and techniques that enable unobtrusive JavaScript, but jQuery on my opinion is one of the best. It supports Unobtrusive JavaScript nicely and very elegant by itself.

Inline JavaScript Unobtrusive JavaScript
Have you rjavascript:void(0)
Publish Postead our
<a href="javascript:window.open(
'terms.html', 'popup',
'height=500,width=400,toolbar=no'
);">terms and conditions</a>?
Have you read our
<a href="terms.html"
  class="sidenote" >terms and conditions</a>?

jQuery(function($) {
  $('a.sidenote').click(function() {
    var href = $(this).attr('href');
    window.open(href, 'popup',
    'height=500,width=400,toolbar=no');
    return false;
  });
});

You may decide that the second way is more verbose, but it does not matter in general. You will have all handlers in a single place, they will be quite similar and document structure will not suffer from tons of inline javascript.

Capterra Top 20
Capterra Top 20
Project Portfolio Management
May-20
GetApp Category Leaders
GetApp Category Leaders
Project Portfolio Management
Jul-20
GetApp Category Leaders
GetApp Category Leaders
Roadmaps
Jul-20
Software Advice FrontRunners
Software Advice FrontRunners
Product Management
May-20
Software Advice Recommended
Software Advice Recommended
Product Roadmap
Mar-20
Software Advice Customer Support
Software Advice Customer Support
Project Portfolio Management Software
Jun-20

Subscribe to the latest updates

Thank you!

Сheck out latest blog posts: Show all

Or contact
a sales representative

Get a live
product demo

Let one of our product specialists create your account
and shape Targetprocess for your company needs.