Created
September 25, 2024 09:23
-
-
Save Dj0ulo/23e2dfb541fc39781eff63bc410df06f to your computer and use it in GitHub Desktop.
This file contains 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
if (window.matchMedia("(max-width: 768px)").matches) { | |
const originalCreateElement = document.createElement; | |
document.createElement = function(tagName) { | |
const element = originalCreateElement.call(document, tagName); | |
if (tagName.toLowerCase() === 'script') { | |
Object.defineProperty(element, 'src', { | |
set(value) { | |
element.setAttribute('data-cmp-src', value); | |
element.setAttribute('src', ''); | |
} | |
}); | |
} | |
return element; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment