Jump to content

Talk:Unobtrusive JavaScript

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

POV going to be removed

[edit]

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)[reply]

Is 'Unobtrusive JavaScript' a distinct concept worthy of a wikipedia article?

[edit]

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)[reply]

A Google search for the phrase "unobtrusive javascript" turns up 138,000 results. It's been formally discussed at web development conferences. The influential site alistapart.com has an article about it. The term is commonly used, with the meaning that's described in this Wikipedia article, on mailing lists, blogs, and web development tutorials across the web: example, example, example. (Examine the example sources from the last link to see that the term is, in fact, being used to describe a specific methodology that stresses separation of programmatic behavior from markup.) People have written class libraries specifically to faciliate unobtrusive JavaScript development. This blog actually uses the phrase "unobtrusive JavaScript movement".

Need more? :) Greenie2600 04:04, 27 January 2007 (UTC)[reply]

Fair enough. I'm reasonably happy. Artw 17:08, 27 January 2007 (UTC)[reply]

Since the issue seems to be resolved, I removed the sources needed flag from the main page. Amitchaudhary 01:25, 1 February 2007 (UTC)[reply]

Doesn't the example lead to a memory leak?

Burn the heretic!

83.70.247.123 22:59, 25 July 2007 (UTC)[reply]

Emerging trend? People have advocated this kind of thing for years. —Preceding unsigned comment added by SigmaB8a (talkcontribs) 16:08, 20 September 2007 (UTC)[reply]

While I'm sure that there are earlier examples of Unobtrusive JavaScript the earliest that I am aware of are from Microsoft with IE4 and Behaviours (HTCs - HyperText Components) which unlike the current trend formally specifies the interface and seperation of the JavaScript from the markup that its acting upon. With Behaviours JavaScript is attached by means of CSS.

The current MS documentation on Behaviours can be found on MSDN [1]

It's my personal view that we'd be a lot further along if the work MS did in this area had been paid more attention. Carnagh 09:01, 24 September 2007 (UTC)[reply]

I think the relevant point here is that we're really talking about "unobtrusive" "JavaScript", not "Unobtrusive JavaScript". I.e. a qualification and design principle applied to the use of one programming language, not some singular, well-defined, noteworthy concept, idea, movement, programming ideology, topic, or anything even vaguely resembling something that would warrant an article in an encyclopedia. I mean, can anybody even define what makes a certain piece of JavaScript "Unobtrusive", as against just unobtrusive/in-accordance-with-good-coding-practice/good-as-in-not-as-bad-as-javascript-used-to-be?

Then, as a counter example, certainly there are quite a number of references in the literature to "nice girls" or "posh homes". Probably more than one book has been written about both, and articles with those sorts of titles abound even in the academic setting. But that happens not because the topic is well-defined and worthy of an encyclopedia article; rather it happens because the choice of words, and in particular the clarification afforded by the preceding, grammatically productive adjective, is both easily thought of and germane to the situation.

Clearly none of this makes for a concept worthy of description separate from the underlying terms. We already know what "unobtrusive" means, as well as "JavaScript". "Unobtrusive JavaScript" seems to me to be simply the usual productive combination of two terms, without any extra, autonomous content/meaning. As such, I'd conclude that the article at most ought to be merged with JavaScript, as a modern historical sideline on the usage patterns of the language, if not outright deleted.

Decoy (talk) 17:44, 5 August 2008 (UTC)[reply]

Incorrect example

[edit]

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 (talkcontribs) 08:29, 1 July 2010 (UTC)[reply]

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)[reply]

Namespace pollution

[edit]

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)[reply]

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>
<h1 id="x">Test</h1>
<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)[reply]

Event names

[edit]

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)[reply]

Is 'Unobtrusive JavaScript' an historic opinion piece?

[edit]

This section supports the "Is 'Unobtrusive JavaScript' a distinct concept worthy of a wikipedia article?" and "POV going to be removed" sections above.

In late 2016 many internet applications use technology totally dependent on JavaScript operation in client browsers using standardized DOM models. Browser's themselves have moved to a constant update model so that users are less subject to slow operating system releases of particular browser versions. Multi billion dollar corporations operate on the internet using JavaScript. Turning JavaScript off has been removed as an accessible option in major browsers.

The section name "A new paradigm" appears to be largely self-aggrandizing and dates the content. Multiple references ([3] through [6]) to the same JavaScript commentator suggest an alignment of opinion at that point in history. The entire "Best practices" section is opinion introduced by the weasel words "advocates of the paradigm generally subscribe to".

Without promoting absolute removal of the article, I think clarification that it is mostly opinion, perhaps generating conference and book articles at the time, needs attention. Perhaps there a "D" grade category of articles?

Dom1953 (talk) 05:39, 7 December 2016 (UTC)[reply]

I fully agree. The use of the word "new" (in the title "A new paradigm") should have had alarm bells ringing. This text is nice for a blog post, but not for a Wikipedia article. Saying "JavaScript historically has had a reputation for being a clumsy language unsuitable for serious application development" is also a clear POV with weasel words. -- Peter (talk) 08:30, 16 January 2020 (UTC)[reply]
The article should not be an opinion piece, of course, per basic Wikipedia guidelines, and the term seems to have been more relevant in the past than today, so it may indeed be "historical" (Wikipedia covers historical material).
I have removed the offending paragraph that Pbb mentioned above, as well as the most obvious relative time references (MOS:RELTIME). I removed the bullet point about "scalability" in the lead, because it was unsourced and the term is not sourced elsewhere in the article. I also tagged the article with {{Update}} and pointed to this talk page section.
Contra what Dom1953 said above in 2016, people still turn JavaScript off for various reasons (see, for example, the references in mw:No-JavaScript notes at the MediaWiki wiki), sometimes through a corporate proxy and sometimes selectively via browser extensions such as NoScript, although the overall average percentage of people who do so is very low. (Wikipedia accommodates such people: Wikipedia works very well with JavaScript disabled.)
In summary, the page needs to be updated and sources should be improved. Biogeographist (talk) 14:16, 16 January 2020 (UTC)[reply]
You are right that "people still turn JavaScript off". I don't think the phrase "Unobtrusive JavaScript" was ever popular, mostly because there is no concrete meaning assigned to it. Most likely, different people just used word "unobtrusive" as an adjective to describe code they write and not as a phrase. There are basically no sources that could be used to improve this article and present content is unfocussed and unclear because it actually describes few different perspectives on what is "good" JavaScript. This article makes no sense because it tries to describe just "good" from multiple different perspectives. Anton.bersh (talk) 10:24, 30 June 2021 (UTC)[reply]
You have helpfully suggested how this article should improve, but it is not true that there are no sources that could be used to improve this article. There are such sources, and they should be used to improve the article. If the sources present different perspectives, and perhaps even contradict each other, that variation should be described in the article. The existence of different perspectives does not mean the subject is nonsense. Biogeographist (talk) 21:47, 1 July 2021 (UTC)[reply]
Yes, this article is an opinion piece. "Unobtrusive JavaScript" is just a tag invented by some developers to promote their vision of software. As mentioned in the article, "there is no specific formula" for "Unobtrusive JavaScript". Note that many of these ideas were not invented by the creators of "unobtrusive JavaScript" phrase, but instead recognized as a good idea and given a specific name. Some individual ideas became popular but under different names ("Degrading gracefully" section describes Progressive enhancement, "Namespaces" just urges developers to be aware of variable scoping (closures, block-scoping, etc.). This article is basically a re-print of a few oppinion pieces about how to write decent JavaScript. The phrase "Unobtrusive JavaScript" probably does not meet Wikipedia notability requirements. Anton.bersh (talk) 10:06, 30 June 2021 (UTC)[reply]
I have found multiple independent published sources that I think are prima facie evidence of notability. I will add them to the article shortly. Biogeographist (talk) 21:47, 1 July 2021 (UTC)[reply]
Looking forward to these changes. Anton.bersh (talk) 09:27, 2 July 2021 (UTC)[reply]
@Biogeographist: This entire article still reads like amalgamation of individual tips from lists with similar names. I still think that word "unobrtusive" is used as an adjective and not part of proper noun. I find tons of articles, slide decks, and PDFs with titles like "JavaScript tips and tricks", but that does not make the subject of "JavaScript tips and tricks" notable. Anton.bersh (talk) 08:52, 15 July 2021 (UTC)[reply]
The article is not about tips and tricks; it's about a concept. The term unobtrusive JavaScript is not a proper noun; it's a noun phrase that is also a notable technical term, as the references show. To test your claim that "unobtrusive" is merely used as an adjective and that unobtrusive JavaScript is not a notable concept, I searched the web for unobtrusive + coding. Most of the results were pages about unobtrusive JavaScript. "Unobtrusive" has other meanings apart from client-side JavaScript, but those meanings are irrelevant here. So I don't believe your claim that the fact that "unobtrusive" is an adjective somehow makes unobtrusive JavaScript not a notable concept. That's like saying an analog computer isn't a notable thing because "analog" is an adjective, or the same with "functional" in functional programming, "lexical" in lexical grammar, "randomized" in randomized algorithm, or "threaded" in threaded code. Biogeographist (talk) 02:36, 1 August 2021 (UTC)[reply]

Maintenance and rating of JavaScript articles

[edit]

Concerning editing and maintaining JavaScript-related articles...

Collaboration...

[edit]

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

[edit]

We've found over 300 JavaScript-related articles so far. If you come across any others, please add them to that list.

User scripts

[edit]

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

[edit]

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

[edit]

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)[reply]