JavaScript: Learning part 2 and telecommuting

Filed under: Development, JavaScript, Techy stuff — kathyjay at 8:00 pm on Wednesday, June 14, 2006

I am reluctanctly admitting that JavaScript isn’t as bad as I remember it. I distinctly recall tons of browser sniffing, JavaScript error messages and thoroughly ugly coding practises. That’s still what I usually see if I’m silly enough to go into a script archive looking for something.

But this DOM Scripting book is painting some really elegant coding. No inserting dozens of things that can’t be validated. XHTML Strict does not like onload or onclick events and I’d had no idea that I could put all of that in my external script file - it was one of the many things that kept me away from the stuff for the past couple of years.

There’s an emphasis on graceful degredation, something that is particularly important if you’re interested in accessibility. That means that, if your JavaScript functions aren’t working in your user’s browser for whatever reason, your page should still work even if the functionality isn’t as wizzy as initially intended. The example they’ve used in the early parts of this book is a really nice image gallery script (I’m probably going to be fiddling with it a little further and adding some styling to put into the gallery on this site) that updates a placeholder image in the page dynamically or just takes you straight to the image if the script can’t work. Much better, to me, than half a dozen JavaScript errors and an end result of never seeing any images.

The last time I attempted to learn JavaScript, there were lots of functions that only worked in certain browsers, absolutely no mention of statements such as document.getElementByID and all the examples did such useless things as putting scrolling messages in your status bar (kill those!!) or changing how half the browser worked without good reason. And it was all shoved into the HTML document with no mention of external files, promising hours of updating if any of the script ever needed changing.
I may even be converted to thinking that really good, well-formed JavaScript is a lovely thing.

In the spirit of National Liftsharing Day, shouldn’t we also have National Telecommuting Day? Far too many employers still refuse to understand why telecommuting could be a good thing for them and their primary objection is too often that they don’t trust employees to do the work. I’m not sure about other workers, but I generally get more done if I’m working from home than I do in the office. I tend to work longer and more intensively without distractions. We have the tech to do it well now, so shouldn’t more employers be actively looking for their staff to work from home a few days a week?

JavaScript and DOM: Beginning yet again

Filed under: Development, JavaScript, Techy stuff — kathyjay at 11:25 am on Saturday, June 10, 2006

It turns out that upgrading WordPress is much less painful than I’d assumed.

But to return to the topic, I’ve decided that it’s time for yet another stab at learning JavaScript. Why haven’t I managed this before? Well, it’s certainly not lack of programming ability!

My trawl through the first couple of chapters of “Dom Scripting” by Jermey Keith has reminded me of why I fall away each time. The language has a similar structure to most of the C-type languages such as Java, C++ and PHP. Now, I’m familiar with all of them so those initial chapters always teach me the structures that I already know. By the time the interesting stuff appears, I’ve moved onto learning something else that I can find a more immediate need for.

I’ve been a web denizen since 1999 and at that time JavaScript was essentially The Evil Language. Any website that implemented it had dozens of errors and it was usually put in as a “woo I’m clever” thing rather than for anything actually useful. Over the years, I’ve developed a fairly intense dislike of bad JavaScript and it’s only been over the last couple of years that JavaScript has been used well and unintrusively. The standardisation of the DOM has certainly helped here.

I genuinely enjoy learning new things, but unless it’s a college thing I usually focus on the things that I have an immediate use for. I’ve never had any need to use JavaScript in anything that I’ve worked on and the odd bits that I have used were picked up from magazines or tutorials and I’m good enough with languages to adapt things to what I need. PHP, on the other hand, I could see a use for which is why I sat down and learned it last year. I had a project in mind for it and it’s turned out very well.

JavaScript, though, is a necessity if I really want my web career to go anywhere so it’s time to hit the books again. This time I’m going to get past the “here is a variable, look at this for loop” section and actually find the stuff that I can use in the real world.

As an aside, am I the only geek out there who infinitely prefers using a for loop over a while? My colleagues at work seem to adore their while loops, but in all those cases a for loop would have been easier to read and maintain. Hmmm.