Talk:Unobtrusive JavaScript

message: User:Backzlider seem to have a few issues with Unobtrusive JavaScript and through the use of many WP:AWW Weasel Words like "it could be argued" he tries to put the concept down. When he says that the article by Stuart Langridge might be called hijacked it is almost entertaining. In that very article Stuart Langridge shows perfect examples of how to add a behavioral layer on top of the HTMl and CSS using nothing but the class attribute in the HTML. Backzliderz's discussion about "browser events" is also very confusing. Bringing back NPOV and simultaneously improving the article will require a general rewrite.
I do not have my copy of david Flanagan's Definitive Guide (5th ed) in which he describes unobtrusive JavaScript (quite favourably, BTW). I will add it as a reference when I get back to my library.
--itpastorn (talk) 11:58, 3 December 2009 (UTC)
thread_title:  POV going to be removed 

message: I'm very much in favour of the techniques this article is suggesting, but it seems to me that it might be a bit of a disguised how-to or essay article, and that 'Unobtrusive JavaScript' might not really exist as a distinct concept worthy of a wikipedia article.
Unless evidence can be dug up of a definite "Unobtrusive Javascript" movement it;s probably a candidate for merger or deletion. Artw 02:36, 27 January 2007 (UTC)
replies: text: Fair enough. I'm reasonably happy. Artw 17:08, 27 January 2007 (UTC)

text: Burn the heretic!
83.70.247.123 22:59, 25 July 2007 (UTC)
thread_title: Is 'Unobtrusive JavaScript' a distinct concept worthy of a wikipedia article?

message: The examples from the "Separation of behavior from markup" section are not equivalent. Firstly, 'document.getElementsByName("date")[0]' will return the first element with a name attribute of "date", which clearly is not guaranteed to be the input we want: other inputs may legally have a name attribute of "date", as could an <a> element. Secondly, the library examples will apply the "change" event to all input elements with name attribute of "date", not just the one we're interested in. I would suggest for clarity and lack of ambiguity that the example should be modified to use an ID to identify the input element of interest.  —Preceding unsigned comment added by Timdown (talk • contribs) 08:29, 1 July 2010 (UTC)
replies: text: I completely agree. Using name attribute as a selector slow, prone to errors, and entirely unnecessary. W3C created the id attribute for the purpose of obtaining a reference to a single element from a script. Look at Wikipedia's own search box for example. I've gone ahead and modified the examples to use the id attribute. --Elephanthunter (talk) 02:28, 22 October 2010 (UTC)
thread_title:  Incorrect example 

message: Isn't there an aspect of 'unobtrusive JS' that says we shouldn't define variables, functions etc in the global namespace? With importation of large libraries ad lib there are bound to be name collisions, so we should all define our stuff in an object or a closure. If everything you define is inside $(document).ready(function(){ ... }, then none of it pollutes the global namespace. This is implicit here, but not mentioned. Shouldn't it be? --Nigelj (talk) 18:51, 26 September 2010 (UTC)
replies: text: Well, a while has gone by, and I've just added something to the article about this. The new example code is tested and work. If anyone wants to mess with it, and re-test, this will help:
<html>
<body>
Test
<script type="text/javascript">
var org;
if (!org) 
    org = {};
else if (typeof org != "object")
    throw new Error ("org already exists and is not an object");
if (!org.example) 
    org.example = {};
else if (typeof org.example != "object")
    throw new Error ("org.example already exists and is not an object");
    
org.example.Highlight = function() {
    // define private data and functions
    var highlightId = "x";
    function setHighlight(color) { 
        document.getElementById(highlightId).style.color = color;
    }
    
    // return public pointers to whatever methods or 
    // properties you want to reveal
    return {
        goGreen: function() { setHighlight("green"); },
        goBlue : function() { setHighlight("blue"); }
    }
}(); //end closure definition and invoke it
org.example.Highlight.goBlue();
var h = org.example.Highlight;
h.goGreen();
</script>
</body>
</html>
--Nigelj (talk) 21:02, 8 February 2011 (UTC)
thread_title:  Namespace pollution 

message: I've changed the event names to the proper JavaScript event handles, i.e. from on-click to onclick. I know that, to a user not familiar with JavaScript, this may now be less readable, but if they're new to JavaScript they should also familiarise themselves with the standard API.
Was there a good reason why we hyphenated the names in the first place?
--Squishysquashy92 (talk) 11:29, 15 September 2014 (UTC)
thread_title:  Event names 

message: Concerning editing and maintaining JavaScript-related articles...
=== Collaboration...===
If you are interested in collaborating on JavaScript articles or would like to see where you could help, stop by Wikipedia:WikiProject JavaScript and feel free to add your name to the participants list. Both editors and programmers are welcome.
 
=== Where to list JavaScript articles ===
We've found over 300 JavaScript-related articles so far. If you come across any others, please add them to that list. 
=== User scripts ===
The WikiProject is also taking on the organization of the Wikipedia community's user script support pages. If you are interested in helping to organize information on the user scripts (or are curious about what we are up to), let us know!
If you have need for a user script that does not 
yet exist, or you have a cool idea for a user script or gadget, you can post it at Wikipedia:User scripts/Requests. And if you are a JavaScript programmer, that's a great place to find tasks if you are bored.
=== How to report JavaScript articles in need of attention ===
If you come across a JavaScript article desperately in need of editor attention, and it's beyond your ability to handle, you can add it to our list of JavaScript-related articles that need attention.
=== Rating JavaScript articles ===
At the top of the talk page of most every JavaScript-related article is a WikiProject JavaScript template where you can record the quality class and importance of the article.  Doing so will help the community track the stage of completion and watch the highest priority articles more closely.
Thank you. The Transhumanist 01:15, 12 April 2017 (UTC)
thread_title:  Maintenance and rating of JavaScript articles 

message: At the top of the talk page of most every JavaScript-related article is a WikiProject JavaScript template where you can record the quality class and importance of the article.  Doing so will help the community track the stage of completion and watch the highest priority articles more closely.
Thank you. The Transhumanist 01:15, 12 April 2017 (UTC)
thread_title:  Rating JavaScript articles