Web Design – Bet You Learn Something From This Javascript Article
While Smashing Magazine is usually content to post lists about visual design, when they decide to roll up their sleeves and get into the code, they really make a post you can believe in. Here’s The Seven Deadly Sins Of JavaScript Implementation.
There’s something here even for experienced scripters. For instance in Sin #1, it never occurs to most of us to protect global variables in a self-contained Javascript code snippet – we write and test it in a page by itself. But put two of these scripts on the same page, and they might play havoc with each other! We wonder how many buggy webpages there are out there suffering from this.
Another great example is Sin #5, where we’re unnecessarily mixing together PHP and Javascript, forgetting that we need to make it easy for future maintainers to edit in one language without breaking the other. We’ve seen scripts that had PHP generating Javascript to generate HTML and CSS all together in a tangled mess, and it’s ugly. It also makes changing it like running through a minefield.
Peter Brittain
Web Design Perth
