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

315
Views
How to use unpkg url-join.js as <script src=...> import?

I'm trying to use urlJoin in my project. I've imported the library/script using <script> tag as the HTML is generated by Django.

<script src="https://unpkg.com/url-join@5.0.0/lib/url-join.js"></script>

The problem is that I can't use urlJoin function - the console says:

urlJoin
VM609:1 Uncaught ReferenceError: urlJoin is not defined
    at <anonymous>:1:1

The function is defined like this:

export default function urlJoin() {
  var input;

  if (typeof arguments[0] === 'object') {
    input = arguments[0];
  } else {
    input = [].slice.call(arguments);
  }

  return normalize(input);
}

Do you know how to use it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The file is an ES6 module. See JavaScript modules on MDN.

You need to:

  • Mark the script where you use urlJoin as a module
  • import it into that script
  • Not have a separate <script> element to load urlJoin.

Thus:

<script type="module">
  import urlJoin from "https://unpkg.com/url-join@5.0.0/lib/url-join.js"; 
  const foo = urlJoin("some", "args"); 
  console.log(foo);
</script>

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!