When an HTML tag contains an attribute with no value set (indicated by no information between the quotation marks) it is said to have an "empty" attribute.
When the empty attribute is a source (src) or link (href) (attributes for which the value is a URI), many browsers will still attempt to connect even if there is no URI value set. This increases overhead and creates delays that can especially cause an issue on Wireless networks where bandwidth is constrained.
This Best Practice describes issues involved with leaving source or link attributes empty, and tells you how AT&T Video Optimizer can help identify files that contain empty attributes so that you can fill them in whenever possible.
The following HTML example shows an image (img) tag with an empty source attribute, and an anchor (a) tag with an empty link attribute.
var img = new Image();
img.src = "";
The HTML specifications indicate that the src attribute should contain a URI, but until HTML5 was introduced there was no specification for the correct behavior when a value is not entered for the attribute.
The Uniform Resource Identifier specification RFC 3986, specifies that when an empty string is encountered as a URI, it is considered a relative URI and is resolved according to a specified algorithm. The specification for HTML5 adds to the description of the src attribute to instruct browsers not to make an additional request.
However, if HTML5 is not being used, different browsers may exhibit different behavior.
- Some browsers make a request to the directory in which the page is located.
- Some browsers make a request to the actual page itself.
- Some browsers don't do anything when the attribute is missing.
The result of all these behaviors is that an empty attribute value can result in additional overhead and delay for your app.
Another issue to be aware of is that template engines and content management systems are often set up to insert links, but if they are unsuccessful, the attribute value will be left blank, sometimes without the developer realizing this has happened.
Best Practice Recommendation
The Best Practice Recommendation is to avoid empty source and link attributes.
AT&T Video Optimizer helps you identify empty attributes by testing the files in your app to see if any of the following attributes are empty.
- iframe src
- href src
- img src
- script src
- link href
If any of these empty HTML source or link attributes are detected, the app will fail the "Empty Source and Link Attributes" test and the test results will display a list of files containing the empty attributes.