Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i stop html5 audio from auto download

Tags:

html

css

audio

I am using this

<audio src="audio.mp3" />

Now that file is big and system automatically downloads it when someone loads the page.

is there any way that when someone press play , only then system downlaods. Because that player is in my every page and it wastes the BW

like image 564
user26 Avatar asked Nov 06 '25 15:11

user26


1 Answers

You can use the preload='none' attribute. Documentation here

The "none" attribute:

Hints to the user agent that either the author does not expect the user to need the media resource, or that the server wants to minimise unnecessary traffic. This state does not provide a hint regarding how aggressively to actually download the media resource if buffering starts anyway (e.g. once the user hits "play").

Your HTML could look something like this:

<audio preload="none">
  <source src="audio.mp3" type="audio/mpeg" />
  Your browser does not support this audio type.
</audio> 
like image 60
karthikr Avatar answered Nov 08 '25 09:11

karthikr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!