Posts Tagged ‘JavaScript’

Android Chrome does not allow applications to play HTML5 audio without an explicit action by the user

February 22, 2014 Leave a comment

I was working a site that required to play some sound effects at different times and when testing on my Android phone, I was very surprised to find that only some of the sounds would play.

I assumed that there must be a restriction on bit rate or something else specific to the sound file as some played fine and others didn’t play at all, all using the same code.

I then stumbled across this chromium issue 178297

It turns out there is a mobile specific restriction put in place to disable playback of media if not a direct result of user interaction.

Now I can see why this exists as I HATE auto play videos and ads and they would be even worse on mobile, however I have a valid use for this.

The reason only some of my sounds worked was some were triggered by a button click, while other were trigged by a URL hash change.

A button click is a user interaction / gesture but hash change is not.

Luckily Philip Jägenstedt has found a work around to the situation by using the first user interaction to “warm up” or initialise each audio element.

This then allows non user interaction events to use the elements moving forward.

His post on the issue, including his workaround is at

I have also put this work around into simple-audio which is a JavaScript module to make playing audio in the browser easier.

Promote JS

February 7, 2012 Leave a comment


Documentation of the JavaScript API sucks… Well it did.


I would assume everyone has as some stage come across the scourge that is w3schools. <- see not linked. Also please don't Google them…

These guys are bad, crap shocking and in many cases just plain old wrong. Unfortunately they take out the top few results in a Google search for most JavaScript methods.


Replace ResultsIndexOf Results


This has been a problem for some time and even blocking them from your search results is not easy.

Fortunately someone has done something about this.

Enter the MDN JavaScript Reference. This has been around for a while and I know a number of informed people go here directly and use it.

Unfortunately it is not high in the search rankings however thus non informed / beginners are not seeing the gold mine of information.

This is something I thought I don't have much control over and just needed to do my best to tell people not to use w3schools.


Last night I attended and spoke at the first BrisJS Meetup for 2012

One of the other speakers Tim Oxely pointed out something which I was not aware of but am very excited about.


JavaScript String .sliceJS String .substringJavaScript String .lengthJS String searchJS Array map


This is great! I get a simple, easy way to promote a far superior reference site and also assist in the SEO for MDN to hopefully one day knock w3schools off the top.

It might not be time to spam F5 at yet but the day will come!


He Likes It!


So I implore you. Every chance you get. Add a link on your site, page, blog or anywhere you can get away with it…


Unreadable JavaScript performance tricks you will never use.

February 7, 2012 Leave a comment


Last night I spoke at the first BrisJS Meetup for 2012

The title of the presentation was “Confusing & completely unreadable JavaScript performance tricks that you will most probably never use.”


For those interested the slides for the presentation can be found here.

(Please feel free to send me a pull request to fix my atrocious spelling…)

As this is an impress.js presentation a decent browser is required to view the correctly but the fall back should work if you are still forced to use a trojan…


Also as was pointed out by Tim Oxely every chance you get link to these guys…

JS String .substring