[nycphp-talk] Thoughts on using JavaScript with no progressive fall-back
Paul Houle
paul at devonianfarm.com
Mon Mar 5 19:43:56 EST 2007
Cliff Hirsch wrote:
>
> Whatever happened to building a robust PHP application and only then
> layering on the client-side enhancements? To me this lack of
> progressive fall-back is just laziness, arrogance, or the victim of
> the usual time pressures. This isn’t an opinionated group — right?! So
> I curious to here what others think.
Well, I've certainly seen people use Javascript validation as a way to
avoid using "MVC" thinking and complexity in the back end app.
Back in 2000 I developed an application for a client who insisted on
Javascript validation and told me that he didn't need server-side
validation... Against my advice. Soon he called me up to complain about
the junk data accumulating in the database because a certain fraction of
people had Javascript turned off.
As a maintainance programmer, Javascript terrifies me. Javascript is a
powerful language, and I've seen beautiful code written in it, but it's
got a number of problems:
(i) Browser compatibility -- I've seen a lot of Javascript break in IE7.
Not just the racy, AJAX style of Javascript, but the pre-2000 form
helper kind of Javascript.
(ii) Bad Smells -- Javascript often gets used as a band-aid to patch up
problems in deficient web applications. (Is a bad smell in itself) As a
result of this, Javascript is often applied in a disorderly way with no
thought about organizing code into functions, how variables are named
and scoped (which can really burn you in Javascript) and how event
handlers get wired in.
(iii) Small System Limitations -- one of the problems that torpedoed
Java applets. The trouble here is that there is a gap between practices
for writing good systems (good for the user, which means they don't an
hour to download) vs. what most people think are good software
engineering practices. (writing generalizable code;) In most cases, it
makes a lot of sense to use libraries and frameworks. On the other hand,
I was thinking about reworking my 3-d viewer Javascript:
http://polyhedra.org/
to use Prototype. It turns out that Prototype is a 40kb download while
my 3-d viewer is 8kb. That kind of ratio would be fine for a PHP
framework, that the client doesn't need to download over a slow link,
but it does make a difference in the Javascript user experience.
---
As for how many people have Javascript turned off, I will share
something. It always seems that it's the gatekeepers of life who run
funky web browsers. It will be the people at your next job interview,
the venture capitalists, the thesis advisor, the people on the grant
committee, who have cookies or Javascript turned off in their web browser.
More information about the talk
mailing list