[TriLUG] Javascript.. why?

Kevin Hunter hunteke at earlham.edu
Sun Dec 14 08:24:41 EST 2008


At 2:44am -0400 on Sun, 14 Dec 2008, Maxwell Spangler wrote:
> A question to the full time web developers out there:  Why so much
> Javascript on web pages these days?

The answers are many.  Good Javascript enables functionality that one 
couldn't achieve or couldn't achieve gracefully with straight HTML/CSS. 
What that means, good or bad, often depends on which side of the 
server/client paradigm your find yourself.  Here are couple of reasons 
off the top of my head.

 From a technical perspective:

- Reduction of server load and bandwidth.
   - e.g. client-side form validation
   - e.g. to update a single element rather than the whole page

 From a marketing perspective:

- Ability to update ads in-place.
   - e.g. when the mouse rolls over a certain content or section
   - e.g. when the user comes back to a tab or window
   - e.g. ads over the in-page content, forcing a user interaction.

 From a user perspective:

- More interactive sites:
   - e.g. WYSIWYG editors in page (e.g. FCKeditor, TinyMCE)
   - e.g. animation (e.g. loading bar)
   - e.g. desktop-like moving of elements around in-page

- Friendlier, faster sites:
   - e.g. client-side form validation
   - e.g. to update a single element rather than the whole page

> So if anyone cares to comment, I'd love to hear some examples of how web
> design has changed in the past few years to use more javascript.  I
> think, for example, I'm seeing much more layout work in js and wondering
> why that's not better in css?

Ideally it would be 'better' than CSS, but in conjunction with CSS.  For 
example, there are certain things which are just better done 
programmatically.  Rounded corners comes to mind.  There are browser 
specific things you can do, or other brute force things, but a simple 
one-liner in JS can make all divs nicely rounded.

The pendulum has also started to swing back as one other reason sites 
may use JS is for browser independence.  That is, the JS libraries that 
have popped up in the last couple of years mean one can write code that 
works on all browsers, rather than having to figure out IE's CSS quirks, 
deal with Firefox & Safari layout differences, or trying to play nice with.

That all said though, the initial thrust of your question was "a lot of 
folks use it and I don't think they need to."  I would have to agree. JS 
is a great tool, in my opinion, but oft mis-utilized.

Kevin



More information about the TriLUG mailing list