Load MP3 or MP4 audio on load

I want to add an audio of MP3 file as soon as my Page loads (preferably through JS).

  1. It should play only once and in the starting
  2. I have gone through W3Schools and Mozilla documentations on the audio element but it doesn’t just work


<source src="../html/TaDum.mp3" type="audio/mp3">
  Your browser does not support the audio element.

My JS:

var vid = document.querySelector("audio"); 
vid.onload = function(){

What is the solution here? Any help is appreciated.

122 thoughts on “Load MP3 or MP4 audio on load”

Leave a Comment