2
votes

I'm new to JavaScript, but I know, that I could set and play some audio file with this code:

player.src = "somefile.mp3";
player.play();

Where "player" is id of my audio tag. My question is: how can I preload the song? Because when I click on button, it plays after 3s delay...

1
maybe starting and momentally stopping playing will help? - karaxuna
I have so much songs and ringtones to play... No, it will not help - user2591042

1 Answers

2
votes

Audio element has preload attribute:

<audio preload="auto|metadata|none"> // auto in your case