YSlow: Avoid empty src or href More Recommendations

Rule Summary

Content
High
Easy
98%

Overview

Empty src or href attributes can cause multiple problems.

How does your site score on this rule?

Details from Yahoo!

You might expect a browser to do nothing when it encounters an empty image src. However, this 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 each 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:

Empty image tags occur more often than you might expect. They can appear in two form:

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

Both forms cause the same effect: the 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

Contribute to this recommendation

Have an opinion, link, or other contribution to share regarding this recommendation? Share it with us and help make the web a faster place!