Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-23-2011, 08:31 PM   PM User | #16
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,553
Thanks: 9
Thanked 480 Times in 463 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
at the risk of hogging the mic...


I'd like to step away for a moment from the usual enhancement vs requirement debate and offer another take on why js is vital.

This is a fairly new argument that might not make a ton of sense to many devs at the moment, but will become increasingly clear over the next few years.

It relates to information access and the changing ways we use browsers.

A major downfall of server-side apps is that they need a server. They also need an active internet connection. If you are in the boondocks, a tunnel, and airplane or one of the increasing common public spaces where phones are jammed, you'll notice a sharp contrast between html5 apps and html3 apps.

consider the following example application; a notepad that stores your notes and lets you edit/review them later.


here is workable client code for the HTML3 version, which uses php to serve and store the notes:
Code:
<html>
<head>
	<title>notes</title>
</head>
<body>
<form action= "mynotes.php"  method="POST" >
	<select size='1' name='notes'>
		<option>Choose a note</option>
		<!-- server populates options here -->
	</select>	
	<input value='Load' type='submit'   name="load"  />
	<input value='Save' type='submit'   name="save"  />	
	&nbsp; | &nbsp;
		

	<label>Name <input  name="noteName" />	 </label>
	<input value='Save As' type='submit'  name="saveas" />	

  <textarea rows='10' cols='80' id='data' name="data" ></textarea>	

</form>	
</body>
</html>


Imagine using this all the time (a stretch i know, but it's an example), and having it chock full of notes. You board a plane from LA to NY and hope to get some work done. Then they make you put your phone in airline mode and you have no internet. now what of your notes? How accessible are they to you, with or without javascript?



now consider an html5 version that lives in a single stand-alone file.
Code:
<html>
<head>
	<title>notes</title>
</head>
<body>
	<select size='1' onchange='if(this.selectedIndex) load(this.value)' id='notes' >
		<option>Choose a note</option>
	</select>	

	<input value='Load'  type='button'  onclick="load()" />	
	<input value='Save'  type='button'  onclick="save()" />	
	&nbsp; 
	<input value='Save As'  type='button'  onclick="saveAs()" />	
	<hr />	

	<textarea rows='10' cols='80' id='data'></textarea>	
	
<script type='text/javascript'>
	function el(tid) {return document.getElementById(tid);}
	
	function load(name){
		el("data").value=myNotes[name];
	}

	function save(){
		document.title="Saved";
		setTimeout(function(){  document.title="notes"; }, 1500);
		myNotes[el("notes").value || "default" ]=el("data").value;
		window.localStorage["notedata"]=JSON.stringify(myNotes);
	}

	function saveAs(){
		var newName=prompt("Enter a name for the note"), 
			elm=el("notes"), 
			si= elm.selectedIndex;
			if(!newName){return;}
			elm.value=newName;
			if(si==elm.selectedIndex){ elm.options[elm.options.length]=new Option(newName); elm.selectedIndex=elm.options.length-1; }
		myNotes[newName]=el("data").value;
		window.localStorage["notedata"]=JSON.stringify(myNotes);
	}

	window.onload=function(){
		myNotes=JSON.parse(window.localStorage["notedata"] || "{}" ) || {};
		var ops=el("notes").options;
		Object.keys(myNotes).map(function(name, index){ ops[index+1]=new Option(name); })
	};
</script>	
</body>
</html>

if you have this page's tab open in the browser, the html file saved on your computer, or you add a manifest attrib to the HTML tag, you can read and save notes during your flight. You control the data, you can edit the look of the app, and you can backup your own notes. Pretty cool features for a usable notepad if you ask me...


now, it's not all black and white, keep these points in mind:
  • the html3 version lets you view notes on more than one machine.
  • The html5 version lets you view notes without the net.
  • the html3 version can get hacked, allowing someone else to steal your notes.
  • the html5 version's notes won't get stolen unless your device does.
  • if your devices gets stolen, the html3 version still has your notes safe and sound.
  • you can recover the notes from the HTML5 version if you have a computer backup, or a firefox profile backup, or if your browser backs up its settings automatically.
  • you can use sync or a plugin to read the HTML5 version notes on another computer, or export the notes to tumblr if needed.


basically, my point is that there is more than one way to build an app, and every implementation choice has it's consequences. You need to weigh your target's needs and capabilities against your app's needed functionality, before making any final choices.


Assuming that one model of interaction or the other is "always" the best place to start can really hamper envelope pushing and/or backward compatibility.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:15.2% IE7:0.5% IE8:8.4% IE9:8.5% IE10:8.5%
rnd me is offline   Reply With Quote
Old 06-24-2011, 12:11 AM   PM User | #17
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by rnd me View Post
Another factor is cost. Despite some number thrown around about development, there are other costs associated with good javascript-less sites. Server-side scripting requires a host, which requires public registration, and usually credit-card payment for the plan.
I don't see hosting costs as an issue nowadays. There are many good free hosting providers around nowadays (also some dodgy ones). I use one of Awardspace's ( see the link in my signature if interested) paid plans but they also offer a free hosting plan with no ads and with access to PHP and MySQL all for free.

Quote:
Originally Posted by rnd me View Post
Also, Lots of folks don't know server-side languages, and the penalty for back-end mistakes is MUCH higher than it is for annoying client-side script errors.
I don't see the point you are making here. Looking at the posts in even just codingforums there are also a lot of people that don't know javascript.
And the penalties for javascript errors can be just as high or higher than server side errors, especially if it is a client-side only web site.


Quote:
Originally Posted by rnd me View Post
But, if you are like the increasing number of developers creating HTML5 applications, i don't see a static fallback as possible or frankly, even desirable. Imagine google docs or maps without javascript...
I think using html5 and css3 for commercial work is akin to playing with fire. You may or may not get burnt since html5 and css3 are not officially released by the w3c yet and are still in development. There is a good chance that html5 when it is released will at least in parts be different to what it is today. Also since browser support for html5 and css3 varies you are currently much more likely to run into browser compatibility issues with html5/css3.

Also, why are you talking about HTML3? HTML4 was born circa 1999 (from memory) and since today's developers seem to be younger and younger I suspect many have not seen or used HTML3 as they were still in nappies when HTML4 came around .

So what are we actually discussing in this thread? No-one is disputing that javascript can enrich a web page's user experience, so it's a "no-brainer" for me - if a functionality (data validation etc etc etc) can only be done using javascript then I use javascript, if it can be done either with javascript or server side I will always do it server side first, so that I don't have to have a Plan B for javascript disabled browsers, and then client side only if required as part of the web site specs.

Quote:
Originally Posted by Philip M View Post
@bullant - As you so often say, everyone is entitled to their opinion.
no problem - at least you agree it's only an opinion and so consequently not necessarily actual fact .

Last edited by bullant; 06-24-2011 at 10:37 AM.. Reason: fixed spell errors
bullant is offline   Reply With Quote
Old 06-24-2011, 02:15 AM   PM User | #18
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,703
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
rnd_me, are you aware that HTML 4/XHTML 1 have been around for numerous years now?

Aside from that, I think there is a general difference in the perception of the internet here: There are those people that see the world wide web as a collection of rich internet applications (like rnd_me) and those that see the web as a bunch of websites (like me). And not every website is an “app” that requires rich interaction or offline use or whatever. Let’s take the e-commerce system, for example, from which this discussion actually originated:

I see no reason why JS would be required in current e-commerce systems except for a better shopping experience. Yet, the systems I had tested and/or struggled with relied on JS for the most basic tasks like adding a product to the cart. There is a regular form with a submit button (“add to cart”). The problem there is that the system adds a value from a select option to a hidden input dynamically upon clicking the “add” button and then submits the form. Without JS it would just submit a wrong value or nothing at all. And stuff like this just isn’t necessary. Likewise, the checkout process is disrupted because some more or less fancy show/hide effect doesn’t work and you can’t continue with the checkout. What the hell?

This is what I mean. And this is nothing that would be overly hard to implement if you do it properly before thinking about nice AJAX effects and what not. The same is valid for websites like Facebook or MySpace or even Gmail that basically live through form submissions and the plain display of data. There is nothing that wouldn’t work without JS (at least in a more basic form). In fact, Google is even providing a plain HTML version of their e-mail program but separately from the “rich” version. I would dare to claim, however, that you don’t need to maintain two separate applications, you could even have one version that works without JS which you can then enhance with all these effects and functionality that make it “fun” and “easy” to write e-mails.

Of course I’m not disputing that you can’t apply this principle to web applications like Google docs or stuff like that because this is clearly based on and only working with JavaScript because of the nature of these programs. This, however, isn’t valid for the majority of the internet which still consists of websites that are there to provide information which is supposed to be accessible to as many people as possible with whatever device they are using. Not without reason is it possible to disable JS in the first place. Browser vendors could as well have agreed on making JS an inseparable part of their program – why haven’t they?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
Samhain13 (06-24-2011)
Old 06-24-2011, 09:08 AM   PM User | #19
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Having got that out of the way - one more time:-

This is as serious and important topic, so I would welcome the views of other senior and respected (and I did say respected) members of this forum (especially Javascript moderators and perhaps even WA) on this topic.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 06-24-2011, 09:17 AM   PM User | #20
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by Philip M View Post
.....so I would welcome the views of other senior and respected (and I did say respected) members of this forum......
thank you for the "invitation"
Quote:
Originally Posted by Philip M View Post
This is as serious and important topic,.....
but I don't think it's as serious or important as you try to make out.

Basically what I do is, if a function (say data validation etc etc or whatever) can only be done client side than I use javascript.

If it can be done on both then I will always do it server side first, so I don't have to worry about javascript disabled browsers, and then do it client-side only if it's required according to the web site specs.

That seems to be a "no-brainer" and very simple and uncomplicated to me.

Last edited by bullant; 06-24-2011 at 09:27 AM..
bullant is offline   Reply With Quote
Old 06-24-2011, 10:34 AM   PM User | #21
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Yes, you keep repeating yourself. I think we have all understood what you are endlessly whickering on about. Thank you. And Good-Night.

The issue is not what you say. The question is whether time and money should be devoted to catering for the tiny minority of people thought to be 1%) who have elected to disable Javascript in their browsers.

I am told that around 2% of users (more in Asia) still use IE6 - but no-one is going to code for IE6.

VIP Stephan's argument strikes me as a somewhat evangelical approach - a counsel of perfection. And it seems to ignore the reality that (flawed or not) a huge number of sites do rely on Javascript for functionality.

Modern logistics theory tells us that customer service levels should be set at typically 97-98% orders met from stock. The costs of attempting to provide a higher level of service (i.e. meet 100% of customer needs) become disproportionate and hence uneconomic. 1% of 1,000,000 is indeed 10,000. But it is still only 1%.

99% of ordinary users would not know anything about Javascript, would not know what its use is or know how to disable it in the browser, still less why this might or might not be a good idea. Only computer experts will surf with Javascript disabled - and they can of course re-enable it if they need to do so to take advantage of the features of some particular site.

My position is still that those who for whatever reason have Javascript disabled in their browsers have elected to do that, and ought to accept and endure the consequences.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 06-24-2011, 10:34 AM   PM User | #22
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,703
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Just so you don’t wonder: I have moved all the irrelevant posts to a new thread called “Philip’s and bullant’s playground” in the Active Members Lounge on http://www.codingforums.com/showthread.php?t=230283. You can get all loose there now.

And just as a general heads-up: In future I’m going to delete everything that’s just meant to disgrace or offend another person and doesn’t contribute to a constructive discussion, even if it’s just a sentence in a post. So, bullant – I’m looking at you right now – if you ever want to see your defamations in public then keep on taking screenshots of them and post them on your ominous other secret website because you won’t see them here anymore as long as I’m around.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
Philip M (06-24-2011)
Old 06-24-2011, 10:40 AM   PM User | #23
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
ok thanks but they're not my websites and I also posted the PM you sent me after which WA sent me an apologetic reply after I forwarded it to him.

Last edited by bullant; 06-24-2011 at 10:42 AM..
bullant is offline   Reply With Quote
Old 06-24-2011, 10:50 AM   PM User | #24
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by Philip M View Post
My position is still that those who for whatever reason have Javascript disabled in their browsers have elected to do that, and ought to accept and endure the consequences.
In my experience, I haven't come across a client yet willing to potentially loose any customers.

For something that doesn't need to be coded client side there is virtually no extra cost to my clients for me to code the function both client and server side and in the few cases where there has been an increase in cost to also code a function in javascript the increase as a % of the total cost of the web site project has been trvial.
bullant is offline   Reply With Quote
Old 06-24-2011, 10:54 AM   PM User | #25
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by bullant View Post
ok thanks but they're not my websites and I also posted the PM you sent me after which WA sent me an apologetic reply after I forwarded it to him.
I would have thought that posting a moderator's PM on another website with the object of bringing codingforums.com into disrepute was quite enough to justify immediate banning.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 06-24-2011 at 11:02 AM..
Philip M is offline   Reply With Quote
Old 06-24-2011, 10:59 AM   PM User | #26
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by Philip M View Post
I would have thought that posting a moderator's PM on another website was quite enough to justify immediate banning.
An extract from my PM to WA and cc'd to the mod as a courtesy to keep him in the loop.

Quote:
Now that others have seen VIPStephan's PM as well it is reflecting extremely poorly on his integrity and character......
I am legally entitled to show it to whoever I like to get an opinion on whether it is slanderous and/or defamatory. WA replied saying he had spoken to the mod over the contents of his PM to me.

Last edited by bullant; 06-24-2011 at 11:08 AM..
bullant is offline   Reply With Quote
Old 06-24-2011, 11:10 AM   PM User | #27
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
And codingforums is legally entitled to ban trouble makers with or without giving a reason. I am amazed that WA would seek to undermine his moderators in such a way - especially to you. In fact, I do not believe you.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 06-24-2011, 11:15 AM   PM User | #28
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Quote:
Originally Posted by Philip M View Post
If WA had felt that somehow VIP Stephan had made unacceptable comments then he would have raised the matter with him privately.
An extract from WA's reply to me:

Quote:
I've contacted VIPStephan reminding him of his obligations as a mod to always maintain a high level of professionalism when communicating with members. Sorry about that.
I thanked WA for his reply. Imo WA acted promptly, appropriately and professionally in dealing with the PM VIPStephan sent me.

If you have any issues with the way it was handled then take it up with WA directly.
bullant is offline   Reply With Quote
Old 06-24-2011, 12:31 PM   PM User | #29
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Quote:
Originally Posted by Philip M View Post
This is as serious and important topic, so I would welcome the views of other senior and respected (and I did say respected) members of this forum
Good job I'm not paranoid or sensitive.
MattF is offline   Reply With Quote
Old 06-24-2011, 12:42 PM   PM User | #30
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by MattF View Post
Good job I'm not paranoid or sensitive.
I'm not paranoid! Which of my enemies told you that?
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:58 PM.


Advertisement
Log in to turn off these ads.