Trivial JavaScript

I’ve been chatting with the Free Software Foundation and they’ve posed a tricky question: What is trivial JavaScript? – or – What is not trivial JavaScript?

It seems like an especially hard question to answer – especially without using subjective terms.

For example I would say that the following are all trivial:

  • Use of inline JavaScript/DOM 0-style code (ex. onclick=”…”).
  • Use of unobtrusive scripting to layer on basic page behaviors (ex. Twitter).

Whereas the following are sufficiently complex as to be deemed not trivial:

  • Applications that do Ajax requests to a server-side component (ex. GMail).
  • Applications where the majority of the initial download is executable code (ex. 280 Slides).
  • Applications that are unable to function without the use of JavaScript (ex. Google Maps).

But this brings up the question: What about poorly-designed pages that have a small amount of JavaScript but are unable to function without the use of JavaScript? I’d still deem it trivial.

And what about sites that are somewhere in-between? For example Netflix has a significant amount of unobtrusive JavaScript on their site but I would hardly consider it to be trivial (pop-ups, Ajax-loading, all sorts of unobtrusive interaction).

Is there a tangible line that is crossed on the road to complex JavaScript development? Is it an externality like storing script in a separate file (ex. <script src=’…’></script>)? or is it inside the script itself like in using Function prototypes or closures? It feels like the measure should be put upon an external source (as to not make restrictions upon what someone could, or couldn’t, write using the language) but what would the proper external measurement be?

Thoughts?

Posted: June 10th, 2008


Subscribe for email updates

25 Comments (Show Comments)



Comments are closed.
Comments are automatically turned off two weeks after the original post. If you have a question concerning the content of this post, please feel free to contact me.


Secrets of the JavaScript Ninja

Secrets of the JS Ninja

Secret techniques of top JavaScript programmers. Published by Manning.

John Resig Twitter Updates

@jeresig / Mastodon

Infrequent, short, updates and links.