2

A friend of mine is programming a web page. Instead of writing any HTML in the .html file, he is outputting the entire website with javascript. Excluding SEO, or the fact that it will be a pain to debug, what are the downsides to this? Also, if there is an upside, what would an upside be?

ddan
  • 295
  • 1
  • 5
  • 17
  • 1
    [Atwood's Law?](http://www.codinghorror.com/blog/2009/08/all-programming-is-web-programming.html) – BoltClock Mar 29 '12 at 01:56
  • @BoltClock so are you saying, "as long as it works, then it works"? – ddan Mar 29 '12 at 02:00
  • I dont see why it should necissarily be a pain to debug. Developer tools these days are quite good. Also use qunit or similar for writing tests. – Martin Hansen Mar 29 '12 at 02:46

3 Answers3

2

As you are already aware, SEO is a big deal. SEO is usually the elephant in the room (e.g. the big deal) for javascript-based web-sites and you either forgo SEO or have to somehow design an alternate path that the search engines can index you via and that doesn't run afoul of their rules about serving different content to search engines.

Some potential downsides:

  • Accessibility - access via screen readers and other tools that may be geared to the page HTML.
  • Mobile - Sometimes rendering the page will require larger downloads, more javascript code and more data and more CPU to build the page than a simpler server-rendered page. This may cause compromises on small devices without a lot of bandwidth or horsepower.
  • Performance - The initial page display time may be slower as you can't render anything until all data and code has been downloaded and run. Subsequent page times might be faster or slower depending upon how the app is written. Sometimes you save server trips by doing client-side rendering (which could be faster), but sometimes it's slower to do things on the client.
  • Security - Somethings simply can't be secured client-side the way they can server-side.
  • Code secrecy - Code in browsers is open to the world to see. Code on servers can be kept secret.
  • Same-origin limitations - Browsers are much more limited in who they can contact than servers are because of the same-origin limitation.
  • Memory - Lots of code and lots of data can consume a lot more memory for your app than a server-generated HTML page. This probably isn't meaningful on a desktop, but could be on a smaller device.

Some of the upsides:

  • The content can be dynamically rendered with lots of smarts based on the type of user, the screen size, the capabilities of the device, etc... and this local rendering can generally be done more effectively than trying to do it on the server.
  • You can often do lots of the functions of the app without ever reloading the page, just fetching data from the server or issuing commands to the server with ajax and never reloading the page.
jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • This is the biggest problem, although you can get around it by detecting the robot and serving it custom content (dangerous, if you get caught I believe you get punished pretty harshly.) The whole #! hashbang thing might be able to help in a more legit way too. – david Mar 29 '12 at 02:02
  • The question specifically states that he wants reasons other than SEO. – Martin Hansen Mar 29 '12 at 02:51
  • @MartinHansen - I know that. I wanted to emphasize that even though they said they were asking about things beyond SEO that it's usually the killer issue with JS page rendering. And, then I added some other issues relative to the question. – jfriend00 Mar 29 '12 at 02:58
  • I added a bunch more possible downside issues. – jfriend00 Mar 29 '12 at 06:38
1

One big downside may be mobile.

Depending on the functionality, a javascript-only page may be slow for those on mobile devices.

The pages may be resource heavy, if you are using one or more libraries and / or accessing lots of information. This could also cost a fair amount for those on mobile devices.

Another downside could be accessibility. Not sure how enabling software for low/no vision users would work with a js only site.

Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86
0

My opinion that such kind of coding is more appropriate for members only areas, that of course are not reachable by search engines.

Provided that you use a good library, that is able to do the layout for you, such as ExtJS, it's an interesting coding. You can build web applications that look similar to desktop applications. Browser differences are smoothed out by the library and expect to have very few problems, if any.

For public websites, in general the SEO argument is a pretty big one. If nobody can find you...

stivlo
  • 83,644
  • 31
  • 142
  • 199