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

162
Visualizações
Javascript adding custom meta tags, css and/or scripts to the head or before the </body> tag

I have a react/redux page that makes a call to an API that in the response that can return things that will need to be added to either before the </head>(head) or before the </body> (footer). They can be custom meta tags, css and/or scripts. I tried doing window.document.head.appendChild but that only works on nodes and I have to create the element.

The response should come back in the correct format so for example

<meta name=test123> <script type=text/javascript src=test123></script>

I tried doing window.document.head.innerHTML = <script ...> which appends it to the top but then it messes up all of the styling for some reason. When I did window.document.head.innerHTML += <script ...> it caused lots of repeats.

So I was wondering what's the best way to do this because from the googling I've done I've only seen the appendChild mentioned most of the time.

Also what would the best way to append it to before the </body>(footer) tag?

about 4 years ago · Santiago Trujillo
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