Autoplay Video in Lazy-Loaded Breakdance Popup

Published:
25 Jun 2025
Updated:
02 Apr 2026

Breakdance popups are not in the DOM when the page loads — they get injected only when triggered. This means a standard autoplay attribute on a video element will not work, because the element does not exist yet at page load.

The Problem

You cannot simply place a video inside the popup and expect autoplay to work. By the time the user opens the popup, the browser has already finished its initial autoplay check — and nothing fires.

The Solution

Use a MutationObserver to watch the popup wrapper for CSS class changes. When Breakdance adds the breakdance-popup-open class, inject the video element dynamically. When the popup closes, remove it — so the video resets on next open.

Setup in Breakdance

  • Add an empty Div inside your popup
  • Give it an ID — e.g. video-container-14794
  • Give your trigger button an ID — e.g. video-popup

JavaScript

Add this to Code Snippets. Replace the popup ID 14794, container ID and video URL with your own values.

How to Adapt It

  • Replace 14794 with your actual Breakdance popup ID
  • Replace video-container-14794 with your div ID
  • Replace the video URL with your actual MP4 path
  • To stop video on close — keep container.innerHTML = "" in the else branch

Why MutationObserver?

MutationObserver watches DOM attribute changes in real time. When Breakdance toggles the open class on the popup, the observer fires instantly — no polling, no delays, no missed triggers.

Matus Trgina
- Founder of Shapeusto

Get it done.

Pause or cancel any time

If you don't need our services, there's no reason to pay. Just pause your subscription.

48 hour average delivery

We work incredibly fast. We can create most tasks within 48 hours.

Unlimited requests

Simply enter the number of tasks you need to solve, and we'll take care of all of them.

Unlimited users

An unlimited number of team members can add tasks to us.

Pause or cancel anytime

If you don't need our services, there's no reason to pay. Just pause your subscription.

48 hour average delivery

We work incredibly fast. We can create most tasks within 48 hours.

Unlimited users

An unlimited number of team members can add tasks to us.

Unlimited requests

Simply enter the number of tasks you need to solve, and we'll take care of all of them.
Headquartered in European Union, Slovak Republic
© 2026 Shapeusto. All rights reserved