Automatically launch videos in the description on the product page

Topic summary

A user encountered an issue where autoplaying videos in product descriptions stopped playing when customers selected product options (variants). The video used standard HTML5 autoplay attributes but was interrupted by partial page reloads triggered by variant selection.

Technical Cause:
Selecting product options triggered AJAX requests that caused partial page reloads, interrupting the video’s loop and autoplay functionality.

Solution Implemented:
A helper created a custom Liquid section called “video-2” that:

  • Wraps JavaScript code in proper <script> tags to listen for variant selection changes
  • Automatically replays the video when options are selected
  • Includes a customizable input field allowing videos to be added via URL

Outcome:
The solution was tested in a theme preview, then published to the live store. The user confirmed the fix worked as intended and expressed gratitude for the assistance. The helper offered continued support via email if needed.

Summarized with AI on November 15. AI used: claude-sonnet-4-5-20250929.

Sorry, there was a typo mistake :


it is the same code but we wrap javascript code with a script tag.