Archive for January, 2010

Friday, January 8th, 2010

sIFR vs Typeface.js: The Verdict

[Update: If you're looking for the typeface.js :hover workaround, it's here]

Months ago, in my mission to find a good solution for using fancy fonts on the web, I had a choice between sIFR and typeface.js. sIFR uses Flash to render text, and typeface uses the <canvas> element (or VML in IE). Other than the difference in implementation, however, their feature-set looked about the same, at least for my simple purposes: they were both javascript driven, both allowed text to be selected, and they both looked damn good.

But typeface.js had one crippling debilitation. It didn't have :hover support. Weak. So I went with sIFR.

First, I found sIFR's configuration to be a pain. Well, that's OK. I only have to learn the setup once, then I can copy+paste my code.

Then I found that it had z-index issues in IE, particularly when using them as links and tying the :hover directive together with an image change. Annoying, but it's flash based and IE is always a pain. Fine.

Then I noticed that my jQuery animations (slide effects) were slowed down when sIFR elements were included in the animated element. Hmmm.
READ MORE»

View Comments

Wednesday, January 6th, 2010

How to check if a file exists using JQuery

The best way to do this is with an AJAX HEAD request. HEAD requests only ask for and return the header from the destination file, so they're much faster than POST or GET requests. Perfect for a simple file check.

It's also worth noting that a HEAD request also returns the content length and last modified date, and that jQuery has an "ifModified" option for the .ajax function that returns a boolean value.

Quick code snippet:
$.ajax({
url:'http://www.example.com/somefile.ext',
type:'HEAD',
error:
function(){
//do something depressing
},
success:
function(){
//do something cheerful :)
}
});

Couldn't be easier!

Tags:
View Comments

Copyright © 2009 Rajeev Singh