Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda