Skip to content

Instantly share code, notes, and snippets.

@joshuafredrickson
Created October 29, 2025 21:47
Show Gist options
  • Select an option

  • Save joshuafredrickson/dfafcbf1d9bf62070442595796ab013e to your computer and use it in GitHub Desktop.

Select an option

Save joshuafredrickson/dfafcbf1d9bf62070442595796ab013e to your computer and use it in GitHub Desktop.
Fix YouTube 153 errors in Slider Revolution
(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 });
})();
@joshuafredrickson
Copy link
Author

This will address the YouTube 153 error on Slider Revolution background videos. Add it to the Custom JS section of your slider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment