happyworm/jPlayer — Issue #56: clearMedia makes extraneous HTTP request
Author: marcn
Created: 2011-11-01 21:34:33+00:00
State: open

When playing audio in IE9 using native audio, if you call jPlayer("clearMedia") it will make an extra request for the root document of the current directory (for example "/"). I have traced the cause of this to the setting of the **src** attribute on the **audio** tag to "". The problem is that most browsers interpret an empty **src** attribute as an actual path relative to the current page. See http://developer.yahoo.com/performance/rules.html#emptysrc for more information.

Fortunately it seems that most browsers that I've tested, such as Chrome, Firefox, and Safari do not attempt to load the file as soon as the **src** attribute is set, so this does not appear to be a problem for those browsers. However, in IE9 it does immediately request the document via HTTP.

We are seeing this on our site each time a song ends and plays a new song. A request is made for our home page which then sends 200k over the wire. Not only does this waste bandwidth, it throws off server reports.

Steps to reproduce:
1) Start IE9 and open the Dev Tools window (F12)
2) Click on the Network tab and "Start capturing"
3) Load the jPlayer demo page at http://www.jplayer.org/latest/demo-01/
4) Play the song for a few seconds, then pause
5) In the dev tools, click on the "Console" tab and type the following into the console:
$("#jquery_jplayer_1").jPlayer("clearMedia")
6) Go back to the "Network" tab and notice that a request to http://www.jplayer.org/latest/demo-01/ has been made

Workaround:
By changing the jPlayer code to set the src to "about:blank" instead of "" it seems to fix this problem (or forcing Flash but that's pretty heavy handed just to fix this bug)