?

Log in

No account? Create an account
Gavin Greig [userpic]

JavaScript foolishness

December 19th, 2010 (11:10 am)
current location: KY16 8SX

It’s possible to do some cool things with JavaScript, but fundamentally the whole language is still an evil hack that we’re stuck with because it’s widespread, requiring clever hacks like jQuery to hide some of the unpleasantness. A prime example of hackishness – which will no doubt be fixed once they realise just how foolish it is – has  appeared on the pages of the Herald.

Premium content on heraldscotland is now only available to registered users.” Yes, indeedy, it’s true – sort of. If you visit a “premium” page full of prime journalistic content, like the letters page for example, you’ll see the whole article at first, but before you’ve finished reading it, all but the first paragraph or so will disappear.

…hang on a minute…

So, the whole page is already loaded in your browser, but you can only see part of it? View source…

Yep, the whole thing is still there, there hasn’t been a page reload or anything, it’s just been collapsed down using JavaScript. This is a form of security through obscurity (relying on the user not knowing how to sidestep it), which is a notoriously weak approach to protection.

So far, so daft. But the bit that prompted me to write was this. At the end of the “real” content of the page, there’s a noscript tag (intended for the attention of people browsing without JavaScript, the only people who’ll be able to read the entire page without hassle). It says:

You need Javascript enabled in your browser in order to view this page.

Comments

Posted by: Scotty (scottymcleod)
Posted at: December 19th, 2010 11:20 am (UTC)

always thought of java-script as a hack we ended up with because of netscape and is has developed as hack upon hack - awful doesn't descibe it well enough but sadly it seems were stuck with it as the de facto standard

Posted by: Steve Pugh (very_true_thing)
Posted at: December 20th, 2010 01:29 pm (UTC)
polar bear

That is really quite stupid.

The only reason I can think of for doing it this way would be to keep the full text of the page present for search engines in order to pull in more visitors who then register. However, that runs the risk of being penalised by search engines for not showing humans the same as the spiders see.

It's not really a case of JavaScript's inherent hackiness, more a case of simply not having a clue how the web works. There's lots more in the source code that makes me want to weep.

2 Read Comments