Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
inline and external scripts in the head affect parser

index.html:

<!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <style>
          p {
            color: red;
          }
        </style>
        <script src="script.js"></script>
        <!-- <script>
          console.log('script 1 starts');
          for (let i = 0; i < 3e9; i++) {}
          console.log('script 1 ends');
        </script> -->
      </head>
      <body>
        <p>paragraph</p>
        <script src="script2.js"></script>
        <style>
          p {
            color: blue;
          }
        </style>
      </body>
    </html>

script.js:

console.log('script 1 starts');
for (let i = 0; i < 3e9; i++) {}
console.log('script 1 ends');

script2.js:

console.log('script 2 starts');
for (let i = 0; i < 3e9; i++) {}
console.log('script 2 ends');

When I run this HTML file in the browser what I see is:

  1. Long loading of a browser
  2. Blue colored paragraph

If I comment out external script in the and comment in inline then I see:

  1. Loading of a browser
  2. Red coloured paragraph
  3. Loading of a browser
  4. Blue colored paragraph Question: Why I don't see red coloured paragraph in the first scenario? Should it matter for parser if the script in the is inline or external?
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda