No Mod Required
Archive for January, 2008
A Sketch for 2008
Did I mention I've got a new scanner (more on that later.)
Here are some letters:

YSLOW Performance Grade: F (26)
Any YSLow users out there? If so, can anyone point out a major site with a worse performance grade than either
MSNBC or CNN?. Both scored a wonderful 26!
The number of HTTP requests at CNN is just silly and the overall size is completely out of control:
Empty Cache Primed Cache
18.1K 1 HTML/text
0.0K 5 undefineds
24.1K 13 IFrame/Frames
1.1K 2 XMLHttpRequests
31.0K 2 Flash Objects
326.1K 23 JavaScript Files
520.8K 6 Stylesheet Files
3.2K 45 CSS Images
142.7K 89 Images
1067.4K Total size
186 HTTP requests
MSNB isn't far behind:
195.0K 5 HTML/texts
0.0K 3 undefineds
3.8K 1 IFrame/Frame
66.2K 3 Flash Objects
240.8K 28 JavaScript Files
52.9K 4 Stylesheet Files
21.2K 59 CSS Images
220.2K 81 Images
800.4K Total size
184 HTTP requests
[update]
We now have a new winner. Click through to see who gets an extra fancy 21
Books 2008 #1 Pro JavaScript Techniques
Pro JavaScript Techniques (Pro) Reading this book I finally understand why I don't really immediately grasp JQuery code. Resig's doesn't use verbs for his function names. Instead of something like getElementsByClass(), he uses something like class(). I like verbs in my function names.
That aside, this is an excellent book for the serious JavaScript programmer. Resig does a great job of covering the breadth of modern JavaScript techniques and if you've got a reasonably solid JS foundation you can't help but come away from this book with patterns, techniques and approaches that you can apply to your day-to-day code.
Movies 2008 #3 The Nomi Song
The Nomi Song Know who Klaus Nomi is? I didn't until I saw this film. I'm still not sure what to think about him, but this documentary was an excellent introduction to his life and career. I could write a little bit about him and what his music sounded like, but instead I'm just going to post another Youtube video featuring Klaus in all his glory. That'll go a lot further than anything I could ever write. That's a guarantee. With someone as unique as Klaus, seeing is really believing.
Economists Say Movie Violence Might Temper the Real Thing
NEW ORLEANS — Are movies like “Hannibal” and the remake of “Halloween,” which serve up murder and mutilation as routine fare, actually making the nation safer?
You all know how I feel about movie violence, so I'm biased, but even ignoring that, this is interesting reading.
Good for Vic Ketchman that he doesn't have to suit up.
Because the Patriots are going to be completely fired up for this week's game thanks to him.
Why?
On the jaguars.com Power Rankings, the Patriots are listed with an asterisk.
No. Really.
Is that the stupidest thing you've ever seen? Giving a team that thrives on playing the disrespect card a whopper like that in the week leading up to the game? Is that completely and utterly insane? Yes it is. The Pats should be out of their heads come kickoff time.
And yes, it was published after the regular season and not just for this week- but still. He had to know it was possible (likely?) that th Jags would play the Pats in the first round. maybe he wants to get on Gregg Easterbrook's good side. Or maybe he's been doing it all year? Either way, it's come out now, so things should be interesting this weekend.
[updated]
They pulled the asterisk. What's up with that? Why bother? It's not like the controversy (such as it is) is going to go away because the asterisk is gone. We all saw it. We can't unsee it just because it's gone from the Internet lol
Playing Around With ECMAScript for XML (e4x)
As I mentioned I was reading John Resig's Pro JavaScript Techniques recently (I actually finished it today.) The last chapter deals with the future of the language, and goes into a few different JS related technologies on the horizon- the <canvas> element, Comet, etc. One technology featured I'd never actually played around with was ECMAScript for XML (E4X.) Reading the sample code, I realized it could potentially be really useful, so I decided to take it for a little spin this afternoon, just to get a feel for what it might be like to work with. I came up with the following…
Here's some sample code:
function e4xDemo() {
//create a new div
var newDiv = <div/>;
//append an H1 with some text
newDiv.h1 = "This is an e4x generated header";
//give the div an ID
newDiv.@id= "e4x";
//append an H2 with some text
newDiv.h2 = "let's create a more complicated structure"
//append a whole slew of divs and a paragraph
//this feels like it could be very powerful
newDiv.div.div.div.div.p = "isn't this kind of cool?";
//add another paragraph
newDiv.p = "let's add in an image";
//if E4X was widely supported
//I'd use this pattern all the time
newDiv.p.img.@src="http://media.drunkenfist.com/304/wp-content/uploads/2008/01/graffiti-letter-i.thumbnail.jpg";
//E4X creates a variable of type XML
//Which is basically just a string full XML
//so we use innerHTML to jam it into the doc
$("contents").innerHTML=newDiv;
//Then we spit out the full text of the variable into a PRE
$("view-source").appendChild(document.createTextNode(newDiv));
//use the .. operator that searches all child nodes of a certain type
$("dot-dot-p").appendChild(document.createTextNode(newDiv..p));
return false;
};
And here it is in action (Firefox only):
First impression? It wouldn't completely replace strings+innerHTML or the proper DOM methods like createElement or appendChild, but E4X would come in handy in a lot of situations and if it were more widely supported it would immediately get some use. For example, I'd definitely use the var newImg = img.@src = "path/to/image" pattern all the time when creating images on the fly (it's just so direct) and I'm betting I'd use <div/> and div.@id in place of some of the longer, tougher- to- read strings I drop into HTML docs with innerHTML.
I'm going to continue to experiment with it. I'm going to try to rewrite some of my existing code using E4X, so we'll see what shakes out with the tinkering.




