How to enable autoplay on modern browsers


Problem

On modern browsers, using autoplay is hard. It gets blocked unless you enable hidden settings

Solution

Use my horribly janky JavaScript

To do this, either download the autoplay_enable.js, upload it to your own site and use that (better approach)
or include this code snippit that loads it from my site in the <head> (important) of your page(lazy):

<script src="https://h3.neocities.org/autoplay_enable.js"></script>

It automatically seeks ot any <audio> tag with the autoplay attribute set, so you will not have to change anything. Just use the autoplay attribute as normal. It will not interfere with other JS that pauses/plays audio tags.

How this works

Audio on modern browsers will not be allowed to play, unless its activated by a user interaction like clicking, tapping, keyboard, etc.
The scripts triggers on all of those events and triggers the autoplaying ONCE. This is to not interfere with other JS.
I commented the script a bit so that you can understand it better.