One common method to accelerate web pages is preloading those sources the visitor might need in near future. In HTML such sources are specified by the <link> element with a rel attribute. Currently there are four expressions in use:
- prefetch loads the source and is supported by Firefox (v. 29), Opera (v. 21) and Internet Explorer 11.
- prerender loads and renders the source and is supported by Chrome (v. 35) and IE 11.
- dns-prefetch is self-explanatory and at least supported by IE 11. I skip it here.
- subresource loads the source and is supported by Chrome (v. 35).
A lot of blogs out there assert that one can achieve full cross-browser support by using both prefetch and prerender on the same source. But that is at best only half the truth. Firstly all sources I have read use two <link> elements but according to the HTML 5 spec the rel attribute is a space separated list of strings (well known from the rel="shortcut icon" relation which adds an IE specific expression to the standard one). The following is syntactically correct and well understood by all browsers and remains the best for HTML pages:
According to my tests Chrome prefetches a single file only, too. So preloading of non-HTML sources is not very useful here and one can think of skipping it completely. But the subresource relation that was introduced to Chrome a few month ago behaves in the same way as prefetch. And so the correct solution to non-HTML sources is:
When doing tests yourself keep in mind that a browser is not obliged to preload anything. There may be impacts hard to control.