Posts in "Javascript" tag

Debugging JavaScript with MS Visual Studio

There’s an ancient fable that tells of a frog that falls into a pail of milk. Unable to scramble out, the creature trashes around, seemingly drowning. Eventually however, his frantic struggles turn the milk into butter – and he hops away.

Until now, that fable has been a good metaphor of my struggle with the seven headed beast called JavaScript. I’ve written my lines of code, gotten inane script errors from IE, tried, failed and tried again. Also known, and forever hated, as trial and error programming.

Of course, jolly, happy and cheerful memories from BW2 (before Web 2.0) – when I coded Java all day and all night, with the best tools of the trade – didn’t help much either.

So, I felt like the frog. But that was until I discovered that I could debug javascript with Visual Studio. Yes, that’s right – actual debugging in javascript.

I’m not saying this is news, I’m just saying it’s news to me (and probably to a couple of others as well – those weird looking geeks in the corner, there. See them?). And, yes, I am aware of Venkman.

If you’re not a .net developer, it isn’t in-your-face obvious how you do this, so often you rely on someone just showing it to you. I’ve done some screenshots for you guys and gals.

How to do it!

Just visit the webpage you want to debug with IE. Then fire up Visual Studio, and select Tools -> Attach to Process…

Attach to process Then you find the iexplore.exe instance you want. Click “Attach”.

Attach to process And voilá! You’re in a full-featured debugger; a script explorer, code-view where you can set breakpoints etc. and a panel where you can add watches and view values of locals.

Click for larger version This is brilliant. Now this JavaScript programming should feel less like thrashing in a pail of milk, and more like enjoying a cup of hot chocolate.

1 Way to Impress Your Friends

Or, 24 ways that is. If you’re were sleeping through december month, or maybe too busy handling your mother-in-law, you might have missed 24ways, the ajax/web2.0 advent calendar. The idea is simple; every day they would release a new ajax/web related article. The articles are written by different authors, who are probably considered experts in their field.

It recently struck me how ingenious this is from a marketing point of view. Releasing quality content like this, on a single site and on an pre-known schedule (in this case every day) – you’re bound to get dugg a lot. People also seem find it delicious, and it’s probably just a coincidence that this wasn’t “news for nerds, stuff that matters“.

This will without doubt create a sort of a synergy effect where all the authors get extra traffic (they are all linked to from the article listing in additon to the article). When bloggers get together and release something like this, their chances of getting large amounts of traffic multiplies. Sure, the main site gets hit the most (in this case 24ways.org) – but I suspect the individual authors also got their share (looking at the alexa traffic rankings for a couple of them it seems they had quite an increase in december/january, but that might be coincidental.

Anyway, why didn’t anyone think of this before? (allright, I’m sure someone did and I just failed to do some research, but still – it seems like a good idea to do this for something else than ajax).