We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Just wondering, will this capture document.write() statements?
document.write()
A lot of embeds and other snippets issue document.write() injections synchronously in head or body during page-load.
I'm wondering if MutationObserver would pick these up - and in IE11 in particular.
MutationObserver
Might be good to have test-coverage for this?
The text was updated successfully, but these errors were encountered:
Hey @mindplay-dk, good question!
The answer seems to depend on the browser. I made a small test file to check it out:
<!DOCTYPE html> <html> <head> <script> window.YETT_WHITELIST = [ new RegExp("https://unpkg.com/yett") ] </script> <script src="https://unpkg.com/yett"></script> <script> document.write(` <script src="https://code.jquery.com/jquery-1.12.4.js"><\/script> `) </script> </head> <body> <button onclick="window.yett.unblock()">Unblock</button> <button onclick="alert(window.jQuery ? 'no' : 'yes')">does yett block scripts injected by document.write?</button> </body> </html>
It works with Firefox v80, but not with Chrome v85.
Firefox
Chrome
On a side note, using document.write is very strongly discouraged even though I understand that some tracking companies are still using that.
document.write
With that said, a quick solution would be to group document.write contents into a single call:
<!-- instead of: --> <script src="https://unpkg.com/yett"></script> <script> document.write(` <script src="https://code.jquery.com/jquery-1.12.4.js"><\/script> `) </script> <!-- do: --> <script> document.write(` <script src="https://unpkg.com/yett"><\/script> <script src="https://code.jquery.com/jquery-1.12.4.js"><\/script> `) </script>
Sorry, something went wrong.
These are all third-party scripts - whether or how they use document.write is nothing I have control of.
I'm surprised this doesn't work in Chrome - I suspected this would be a problem in IE, but not in Chrome... 😶
No branches or pull requests
Just wondering, will this capture
document.write()
statements?A lot of embeds and other snippets issue
document.write()
injections synchronously in head or body during page-load.I'm wondering if
MutationObserver
would pick these up - and in IE11 in particular.Might be good to have test-coverage for this?
The text was updated successfully, but these errors were encountered: