Search code examples
htmlaudiopreload

HTML audio preload


I have a sound effect that I need to play whenever someone taps on something but the first tap sound always lags and then it's fine after that. I understand it should have something to do with the preload but I've had preload set to auto the entire time.

<audio id="effect" src="audio/bloop.mp3" preload="auto"></audio>

How can I get rid of that initial lag?


Solution

  • Incase you are using - Safari on iOS:
    Preloading and on iOS devices is disabled to save bandwidth.

    In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it.

    Source: Safari Developer Library