all posts

Updating my YouTube widget to auto load first video

Published to Blog on 12 Apr 2012

A little over two years ago (wow time sure flies) I posted the details of the YouTube widget I use on my home page: Add a YouTube widget to any web site with jQuery. Recently I was persuaded to update the widget to auto load the first video and switch to a given video if the thumnail image of that video is clicked. While I was making the updates I took the time to refactor the Javascript a bit to clean it up and make it more JQuery-like.

You can find a demo here. That example should have everything you need to use the widget yourself.  

Disclaimer: I am definitely no Javascript guru, but I can usually figure stuff out. This seems to do what it is supposed to do in most of the modern browsers I tested with: IE8, IE9, Firefox, Chrome, Opera, Safari on Windows. I also tested with IOS and default browser on Android. It seemed to work well in all those cases.

 

 


Dan Hounshell
Web geek, nerd, amateur maker. Likes: apis, node, mobile, motorcycles, watches, food, Nashville, Savannah, Cincinnati and family. Dislikes: mean people
Dan Hounshell on Twitter