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

310
Vistas
Access a JS file from a different directory

I have a project with the following structure:

project | -

  public | -
    -index.html
  src | -
    -index.js

and the code to import the file is :

<script src="../src/index.js"></script>

and it doesn't work. Any ideas why?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming that public is the only directory exposed with a URL (i.e. you access index.html with http://example.com/index.html): you can't.

The browser can only access the file by requesting its URL, and if you've not put it in public then it doesn't have a URL.


Either:

  • Move the JS file
  • Configure the server to give it a URL via some mechanism other than it being inside the document root.
about 4 years ago · Juan Pablo Isaza Denunciar
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