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

308
Views
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 answers
Answer question

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 Report
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!