I’m having trouble with
I am trying to dynamically load a video background with code. This works in the site preview but in the live site, it shows one video before interrupting it with another. The element does not have a video background in the WYSIWYG editor. I don’t understand why or how this is happening.
My basic code is as follows:
$w.onReady(() => {
console.log('Changing section background');
let section = $w('#mySection');
let background = section.background;
// randomly choose video URL
const videoUrl = getVideoUrl();
if (!background.src || background.src.length == 0) {
background.src = videoUrl;
}
});
Again, this works as expected in site preview. In the live site, it appears one video is loaded than interrupted by the code. Based on when the console message appears, it seems the video is loaded before the code is executed. But the element should not have a video background before my code is executed.
Working in
Wix Studio Dev mode
What I’ve tried so far
Clearing cache and cookies, disabling browser addons