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

240
Vistas
How to load external script file in index.html differently on build mode? (Vue.js)

I am trying to load external script file only on a production mode.
At first, I tried to use NODE_ENV, but found it impossible.
So I compared URL using window.location.host as shown below.

Isn't there a more sophisticated way?

<!DOCTYPE html>
<html>
<head>
...
<script>
  window.addEventListner('load', function(event) {
  let host = window.location.host;
  if (host.match('some production URL')) {
    var script = document.createElement('script');
    script.setAttribute('src', '~.js');
    document.head.appendChild(script);
  }
</script>
</head>
<body>
  </div id="app></div>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
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