Act Fast - Get 15% off GTmetrix PRO Plans now!

Valid only until August 31st - Use code SUMMER2022 to get 15% off the first year of any Yearly PRO Plan! Details and conditions

Recommendations

Lighthouse
Metrics
Audits
PageSpeed (Legacy)
YSlow (Legacy)

YSlow: Avoid empty src or href

Overview

Empty src or href attributes can cause multiple problems.

How does your site score on this recommendation?

Details

You might expect a browser to do nothing when it encounters an element with an empty src or href attribute, however this is not the case in a considerable number of browsers. As of 2016, IE and Edge will both make a request to the page’s parent directory, while Firefox and older Webkit browsers (like Safari) will re-request the page itself! This behavior could potentially corrupt user data, waste server computing cycles generating a page that is never viewed, or in the worst case, cripple your servers by sending them a large amount of unexpected traffic.

Problem Element–Attribute Pairs in Modern Browsers

According to our research, these three pairs will cause needless requests in IE 10+ & all versions of Edge:

  <html manifest="">
  <embed src="">
  <object data="">

Likewise, these two appear to affect all versions of Firefox:

  <video poster="">
  <script src="">

Additional Problem Pairs in Older Browsers

While their later versions aren’t affected, Safari < 5.1, IE < 9, iOS < 6, and Android < 4.4 all make needless requests in the presence of many of these element–attribute pairs:

  <link rel="stylesheet" href="">
  <img src="">
  <input type="image" src="">
  <audio src="">
  <video src="">
  <source src="">

Summary

Content
High
Easy

YSlow 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

Cookie Policy

By clicking "Allow All" you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View cookie details

Deny Allow All
×