I am writing a user script which needs to access specific DOM nodes on the page. To reduce latency and page re-layouting, I want to set it to // @run-at document-start instead of the usual // @run-at document-end, and run my code as soon as the DOM node I need has been downloaded from the server. If I just wa…
Tag: domcontentloaded
Why DOMContentLoaded handler can block first paint?
There is a similar question that wasn’t resolved. I’ve encountered a situation when handler that listens to DOMContentLoaded can block first paint. Sometimes it blocks, sometimes it doesn’t I tried many times cmd + R to see it. Is there any explanation to this behaviuor? Also I recordered a …
Declare global constants in function javascript on DOMContentLoaded
Is there any way to declare constants when the DOMContentLoaded event triggers, that are accessible outside? Answer If the question is: “Is there any way to declare a constant variable without a value, and assign one to it later?”, then the answer is no. Think of it again: after the declaration, a…