YSlow: Avoid empty src or href

You may expect a browser to do nothing when it encounters an empty image src. However, it is not the case in most browsers. IE makes a request to the directory in which the page is located; Safari, Chrome, Firefox 3 and earlier make a request to the actual page itself. This behavior could possibly corrupt user data, waste server computing cycles generating a page that will never be viewed, and in the worst case, cripple your servers by sending a large amount of unexpected traffic.

recommends:

Image with empty string src attribute occurs more than one will expect. It appears in two form:

  1. Straight HTML
        <img src="">
  2. JavaScript
        var img = new Image();
        img.src = "";

Both forms cause the same effect: browser makes another request to your server.

  • Internet Explorer makes a request to the directory in which the page is located.
  • Safari and Chrome make a request to the actual page itself.
  • Firefox 3 and earlier versions behave the same as Safari and Chrome, but version 3.5 addressed this issue (bug 444931) and no longer sends a request.
  • Opera does not do anything when an empty image src is encountered.

Read More

Have an idea for this recommendation?

Feel free to contact us with your suggestions, links or ideas!