Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
¿Cómo cargar un archivo de script externo en index.html de manera diferente en el modo de compilación? (Vue.js)

Estoy tratando de cargar un archivo de script externo solo en un modo de producción.
Al principio, traté de usar NODE_ENV, pero me resultó imposible.
Así que comparé la URL usando window.location.host como se muestra a continuación.

¿No hay una manera más sofisticada?

 <!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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!