Get HTML tags before document.ready (), before executing the DOM

I am looking for a method that allows me to add, remove DOM objects of a page before the DOM is even displayed, I mean that the first JS that I include in the main tag of my page may appear, look for a specific tag that says and removes it from HTML even before rendering it, I know that the javascript call is blocked, since the browser will display my page and come to my javascript in my head, it will block rendering, loading and excecute javascript, now at the time of execution I need to control the previously loaded HTML pending rendering. Is there such a way?

I tried using the properties of the document, but I do not get the tags in js that appear after that js in html.

+3
source share
6 answers

A short and simple answer to this question: NO, it is impossible to do

-1
source

Paste JavaScript just before </body>.

0
source

, DOM IE. , IE6 , " ". , IE8 , .

, html , , , . , , .

0

, - . , , . , , .

0

, script ? script ,

<script>
document.write("<!--");
</script>
<script>// offending script</script>
<script>
document.write("-->");
</script>

(: .)

0

Just run the script tag inside the noscript tag, and then output it if necessary, but regardless of whether javascript is enabled or not, the script will not be executed until it is removed from the noscript tag. Note . You should put javascript in the comment tag so that browsers that don't support the noscript tag still execute it.

0
source

Source: https://habr.com/ru/post/1753354/


All Articles