Created
October 29, 2025 21:47
-
-
Save joshuafredrickson/dfafcbf1d9bf62070442595796ab013e to your computer and use it in GitHub Desktop.
Fix YouTube 153 errors in Slider Revolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| const POLICY = "strict-origin-when-cross-origin"; | |
| function applyPolicy(root) { | |
| (root || document) | |
| .querySelectorAll('iframe[src*="youtube.com"], iframe[src*="youtu.be"]') | |
| .forEach((el) => el.setAttribute("referrerpolicy", POLICY)); | |
| } | |
| // Run once on load/DOM ready | |
| if (document.readyState === "loading") { | |
| document.addEventListener("DOMContentLoaded", () => applyPolicy(document)); | |
| } else { | |
| applyPolicy(document); | |
| } | |
| window.addEventListener("load", () => applyPolicy(document)); | |
| // Watch for iframes that Slider Revolution injects later | |
| const mo = new MutationObserver((mutations) => { | |
| for (const m of mutations) { | |
| for (const n of m.addedNodes || []) { | |
| if (n.nodeType !== 1) continue; // elements only | |
| if (n.tagName === "IFRAME") { | |
| const src = n.getAttribute("src") || ""; | |
| if (src.includes("youtube.com") || src.includes("youtu.be")) { | |
| n.setAttribute("referrerpolicy", POLICY); | |
| } | |
| } else { | |
| // In case an iframe is nested deeper | |
| applyPolicy(n); | |
| } | |
| } | |
| } | |
| }); | |
| mo.observe(document.documentElement, { childList: true, subtree: true }); | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will address the YouTube 153 error on Slider Revolution background videos. Add it to the Custom JS section of your slider.