Adding music to websites

Technically yes you can add music to your site using custom Javascript, but there are some limitations you should be aware of:

  • 22Slides is built with HTML5 and not Flash. HTML5 has many advantages, but playing music across multiple pages is not one of them. The music will start from the top on every page a visitors visits. This is simply a limitation with HTML websites. So because of this, it only really makes sense to add music to your home page and not any other pages of your site.
  • 22Slides cannot host your music files. Almost all tracks have some kind of copyright and are not allowed to be uploaded to a web server to be played on visitors’ computers. In order to add music to your site, you’ll have to first make sure that you can legally distribute the audio file, then you’ll also have to find a place to host them. We recommend using DropBox (There’s a tutorial here:
  • Music can take a very long time to begin playing. Some visitors’ browsers will have to download the entire song before it starts playing, while other browsers can stream the music while it downloads.
  • And finally, the majority of your visitors will find music to be annoying. People tend to enjoy websites that do what they’re expected to do, and playing music through their speakers is almost always unexpected, if not intrusive. The consensus about having music on a website is pretty negative. Any time the topic comes up, you’ll see that almost no one likes it:

So if none of this bothers you, here’s how you can add an invisible music player to the home page of your website:

  1. Upload your MP3 file (after confirming you have permission to do so from the copyright holder) to your Dropbox account and copy the public url. Directions for doing this are here:

  2. Add this code to your “body” field on your custom code page, but replace “URL_TO_YOUR_FILE” with your actual Dropbox public URL you copied earlier:

        $('#page-index').append('<audio autoplay><source src="URL_TO_YOUR_FILE" type="audio/mp3"></audio>');

That should be it! Music should now play on your home page.

music, audio, song, mp3, annoy, annoying, bad, idea

Ask a question or leave a comment

comments powered by Disqus

Can't find what you're looking for? Email us at