Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I read this article Unobtrusive JavaScript with jQuery and I noticed these points in the slide page 11

  • some companies strip JavaScript at the firewall
  • some run the NoScript Firefox extension to protect themselves from common XSS and CSRF attacks
  • many mobile devices ignore JavaScript entirely
  • screen readers do execute JavaScript but accessibility issues mean you may not want them to

I did not understand the fourth point. What does it mean?

I need your comment and responses on these points. Is not using JavaScript and switching to libraries like jQuery worth it?

UPDATE 1 :

whats the meaning of Unobtrusive JavaScript with jQuery ? and yes it does not say we should use libraries but we should have them on external files for that reason i asked my question.

share|improve this question
1  
javascript libraries are, as their name suggests, javascript. If you don't eat peanuts, you won't eat peanut-butter as well. –  Zirak Jul 1 '12 at 9:02
    
i refer to page 11 in the link in my question these points has reference and i asked to be sure by the way the reference written on 6th May 2008 –  shareef Jul 1 '12 at 9:09
    
Do you mean some companies require developers to avoid directly writing plain javascript, but use javascript libraries instead? –  linquize Jul 1 '12 at 9:15
1  
@shareef Yeah, page 11 gives reasons why people turn off js, and not why you should be using a library... –  Zirak Jul 1 '12 at 9:37
    
question rephrased –  shareef Jul 1 '12 at 12:56
show 2 more comments

5 Answers 5

up vote 6 down vote accepted

Here is a jQuery method:

function (deep) {
    if (window.$ === jQuery) {
        window.$ = _$;
    }

    if (deep && window.jQuery === jQuery) {
        window.jQuery = _jQuery;
    }

    return jQuery;
}

As you can see, it is plain javascript. jQuery is javascript. It is a set of methods to help you produce code faster.

jQuery is not something magic.

The "unobtrusive" part can be done using simply javascript.

The thing is, a few years ago, people used javascript like this:

HTML:

<a href="#" onclick="javascript:someMethod();"></a>

JS:

function someMethod() {
}

This is obtrusive, because the javascript code is in the HTML. This is mixing the content and the behavior. Not very good for many reasons (maintainability, mostly).

However, in javascript, you could also do:

document.getElementById( 'someId' ).onclick = someMethod;

function someMethod() {
}

But javascript was seen as an ugly language for kids, so nobody bothered to do anything pretty.

jQuery kind of democratized javascript, and it quickly allows you to do something like:

$( '#someId' ).click( function() {
} );

Which is why it is "unobtrusive javascript with jQuery".

PS: I'm not mentioning the other issues (firewall, mobile, etc) as they are dealt with in the other answers.

share|improve this answer
1  
+1 thanx for clearing the mean of obtrusive i thought its meaning to use external files not inline script –  shareef Jul 1 '12 at 11:26
1  
@shareef it's still better to have javascript in external files for other reasons though (caching comes to mind). –  Florian Margaine Jul 1 '12 at 13:20
add comment

All of your points are completely unrelated to the fact if you are using plain JavaScript or a library such as jQuery (which is written in JavaScript, too).

  • Firewall: If they strip JavaScript, both your library and the code using it will be stripped, too. However, nowadays such a firewall config is extremely unlikely.
  • NoScript: Also blocks both. And people using it will whitelist a site that they want to use if it needs JS.
  • Modern devices usually have modern webkit-based browsers which run JavaScript just as fine as a desktop browser.

You simply misunderstood the article you linked to. It's about making pages work without JavaScript, too, so people who do not have JavaScript enabled for some reason can use your page.

share|improve this answer
    
according to your saying is the reference mistaking –  shareef Jul 2 '12 at 6:04
add comment

jQuery is written in Javascript. It is Javascript. Anything that blocks Javascript will block jQuery (and all such frameworks).

Almost all mobile devices have full Javascript support.

Screen readers are for sight related disabilities. They read aloud what is on the screen.

share|improve this answer
add comment

The last measurement that I saw of those that had JavaScript disabled, was in 2011, and it indicated a continued decline less than 2% of internet users.

Here is a good StackOverflow post that provides similar findings.

share|improve this answer
add comment

Run any method of a librabry writter in javascript, means run javascript. JQuery like library acts as a javascript wrap. If you execute a JQ method on your page, It is going to be executed and translated as a javascript method.

Javascript engine exist in every place you can view a web page.

share|improve this answer
add comment

Your Answer

 
discard

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.