Domestic Goose / Oie domestique

You’ll probably never see it unless you use Firebug or look at Apache raw access logs, but jquery.gritter causes 404 errors repeatedly.
The problem with 404′s is that they are like visiting relatives. They don’t go away unless you do something about it, and you usually can’t be bothered to do something about them – because it’s really not that bad.

Of course, sometimes it is. Especially if you get it on every page load. These errors are annoying and clutter your log, potentially hiding important ones. You also get 404 blindness – and you may miss the “real” 404 that your users see.
Still not convince – just think abot the extra half a second or so your users waste with every page load…

If you look at firebug’s console you’ll see something along the following:

Examining the request (in firebug or Apache access log) shows:

"GET /css/ HTTP/1.1" 404

In firebug, you can also see the referer:

As you can clearly see (click on the image to see clearly…) – the referer of the GET request is the jquery.gritter.css file. This is strange right?

Well, css files can definitely issue GET requests. For example, they may try to load background images. This calls for a quick look into the css file itself:

.gritter-item-wrapper {
    position:relative;
    margin:0 0 10px 0;
    background:url('.'); /* ie7/8 fix */
}

This tries to set a background image on the wrapper div, so that it can solve a nasty IE7/8 positioning bug. However, this results in a GET request to the current directory – which happens to be the css directory. Naturally – this does not end well.

Luckily, the fix is easy. All you have to do is add a real background image. As long as you make it 1px by 1px (or completely transparent) – you’ll be fine and the 404′s will disappear:

.gritter-item-wrapper {
    position:relative;
    margin:0 0 10px 0;
    background:url('../img/blank.gif'); /* ie7/8 fix */
}

Look at your logs/firebug – all good now!

Popularity: 3% [?]

Tagged with:
 

One Response to Getting 404 with jquery.gritter?

  1. JM says:

    Thanks! This has been bugging me for an hour. It’s so obvious once you point it out!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.