let audioPlaying = true, backgroundAudio, browser; browser = navigator.userAgent.toLowerCase(); $('').prependTo('body'); if (!browser.indexOf('firefox') > -1) { $('').prependTo('body'); backgroundAudio = setInterval(function() { $("#background-audio").remove(); $('').prependTo('body'); }, 120000); // 120000 is the duration of your audio which in this case 2 mins. }