4

One of the design proposed for a web application I am working on suggests using javascript to generate all html content. Basically to create a page in the application you would use a homemade javascript framework to build the dynamic html on the page. The pages of this webpage are very complex and all of the html markup would be generated via javascript using our custom built framework. The framework would essentially need a method to create each element on the page you wanted to produce.

What are some of the pros and cons of this approach?

5
  • Does being indexed by Google matter? Commented Dec 22, 2011 at 1:52
  • being indexed by google does not matter Commented Dec 22, 2011 at 1:53
  • @alex: Google is not an issue if you do it right Commented Dec 22, 2011 at 1:54
  • @Amadan: Even if you generate all the HTML with JavaScript? I think it may be. Commented Dec 22, 2011 at 2:03
  • Before committing to doing the whole application that way do a simplified proof-of-concept and check how it works with accessibility tools like screen readers. Commented Dec 22, 2011 at 2:12

2 Answers 2

10

The biggest cons of it are that you must rely on the end user's client browser to correctly render all of your content. An out of date browser or an untested browser is likely to result in broken content or no content. This is distinct from and more severe than the problems those same browsers encounter with HTML & CSS they cannot correctly render. If the markup is supplied to the browser, it may incorrectly render the CSS, but at least the content will be accessible. Using a script to generate all the markup can easily result in no markup being generated.

Then there are the users who run without JavaScript, or with something like NoScript blocking most scripts. They'll not see any of your content either. Thirdly, your content will not be indexed by most search engines.

Addendum

Relating to developer skill sets, working strictly from a JavaScript framework could tromp on the web development division of labor somewhat, if you have such a division. Unless the framework is able to maintain a good separation between the generation of markup, CSS, & application script, your programmers may find themselves more deeply in the role of designer and content editor than they are accustomed to (if you have a division of labor between those aspects of development).

From the comments below, we learn that this is intended for an intranet application in a controlled browser environment. This moots the end-user testing issues mentioned above to some degree, but there is always a danger of a browser upgrade breaking application code in JavaScript.

I cannot think of any positive outcomes that would outweight the potential negative outcomes (by my own judgement, anyway)

Sign up to request clarification or add additional context in comments.

13 Comments

Whats your opinion on using your own custom framework to render html? I think it really locks the application down to the few developers who understand the framework. Also just to provide some more context, this site will be ran on basically an intranet where the browser settings will be controlled.
@kmb385 Anyone can learn a custom framework with enough time and interest and documentation. If there is little will to really flesh out the framework and document it well, that will cause problems for future developers.
You always have to count on the browser to render your content, even with HTML and CSS. Out of date and untested browsers are true of any content, too. Those who run with javascript disabled know what they're in for, too. Your points aren't valid at all.
@Michael—until the site upgrades the standard brower. I've been on sites that are still using IE 6 because they went heavily into ActiveX and are struggling to get away from it. The same scenario occurs with targeting a single corporate browser—you needlessly lock yourself into a single (verson of a) platform.
@Rob If you think this is a good idea, perhaps you should write an answer with pros to rebut my cons. I had hoped viewpoints other than mine would turn up in the answers here.
|
5

The strategy adopted by serious web sites is to start with basic HTML, then add CSS to tidy the layout, then add script to make the users' life easier by enhancing functionality (and not to add time wasting and annoying animations). That way you always have a fallback if something doesn't work or scripting fails for some reason. I deliberately left out the "add annoying advertisements" since they aren't part of the functional design.

To design the site, you should start by determining what it is that your web site is supposed to do (i.e. the vision). Then set out some goals that achieve that vision. Then chose the most efficient design to deliver on the goals—at this point you should not have yet decided on the implementation technology.

Then choose the most appropriate technology and design based on reliability, maintainability, longevity and supportability. That will lead you to a detailed design and implementation.

If, after all that, the best option is a 100% scripted client, so be it. But the fact that very, very few web sites have chosen that architecture makes me very much doubt that it'll be the winner.

5 Comments

+1 I agree. One note about choosing the appropriate technology: the server-side technology may already be restricted to only a couple of choices, or even one choice - where a particular organisation has already invested in, say, ASP.NET infrastructure, they're not likely to take a recommendation to use JSP. (Though perhaps this already comes under your "maintainability" point.)
@nnnnnn—the evaluation of technology options should compare the "best" technically with the current corporate platform. Eventually the bean counters will be won over by least cost (usually over time), whichever one that happens to be (often the incumbent has a big advantage here of course).
@RobG thanks for expressing your views on the issue. Is there a name for this type of strategy? I noticed you called it "100% scripted client". I attempted a google search before posting this question but wasn't sure what to search for.
@RobG would the dynamically generated html get cached by the browser?
No. If it was a popular method for pages, perhaps they would but at present, no.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.