eligrey / eligrey/async-document-write

Automatically inject document.write tracker code into all async scripts

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
68
Forks
14
PR merge metrics
No merged PRs in 30d

Description

This will make `eval(document.write.START)` and `eval(document.write.END)` unnecessary.

If the context is an async script element without an src containing text, add in text and run `script.parentNode.replaceChild(document.importNode(script, true), script)`. I will need to disable document.write() entirely before executing the modified tracker code so that initial runs are ignored.

If the context is an async script element with an src, async XHR/Fetch the src, add tracker code, change src to blob URI for the new content, and run `script.parentNode.replaceChild(document.importNode(script, true), script)`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.