views:

282

answers:

3

This post probably will need some modification. I'll do my best to explain...

Basically, as a tester, I have noticed that sometimes programers who use template-based web back ends push a lot of stuff into onload handlers that then do stuff like load menu items, change display values in forms, etc.

For example, a page that displays your network configuration loads blank (or dummy values) for the IP info, then loads a block of variables in an onload function that sets the values when the page is rendered.

My experience (and gut feeling) is that this is a really bad practice, for a couple reasons.

1- If the page is displayed in an environment where Javascript is off (such as using "Send Page") the page will not display properly in that environment.

2- The HTML page becomes very hard to diagnose, because what is actually on screen is needs to be pieced together by executing the javascript in your head (this problem is less prominent w/ Firefox because of Firebug).

3- Most of the time, this is not being done via a standard practice of feature of the environment. In other words, there isn't a service on the back-end, the back-end code looks just as spaghetti as the resulting HTML.

and, not really a reason, more a correlation:

I have noticed that most coders that do this are generally the coders that have a lot of code-related bugs or critical integration bugs.

So, I'm not saying we shouldn't use javascript, I think what I'm saying is, when you produce a page dynamically, the dynamic behavior should be isolated to the back-end, and you should avoid changing the displayed information after the page is loaded and rendered.

A: 

So the actual question is "What are advantages/disadvantages" of javascript content generation?

here's one: a lot of the things designers want are hard in straight html/css, or not fully supported. using Jquery to do zebra-tables with ":odd" for instance. Sometimes the server-side framework doesn't have good ways to accomplish this, so the way to get the cleanest code is actually to split it up like that.

Jimmy
+1  A: 

I think what you're saying is what we should be doing is Progressive Enhancement with JavaScript.

Also related: Progressive Enhancement with CSS, Understanding Progressive Enhancement and Test-Driven Progressive Enhancement.

Grant Wagner
A: 

This article seems related. Take it easy ;)

ya23
OMFG - someone should be shot for that
seanb