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

259
Views
Hls.js works with a static script tag, but not dynamic

I'm trying to dynamically load the Hls.js library in a (typescript) webpage. When I use a static <script> tag inside <head>, it works without a problem, but when I try to load Hls at runtime it fails with the message Hls is not defined

So this works:

<script src="https://cdn.jsdelivr.net/npm/hls.js"></script>
<script>
console.log(Hls.isSupported());
</script>

But this doesn't (jQuery):

$.getScript("https://cdn.jsdelivr.net/npm/hls.js", (script, status, xhr) => { 
    console.log(Hls.isSupported());
}); 

And neither does a more traditional approach:

const script = document.createElement("script");
script.setAttribute("src", "https://cdn.jsdelivr.net/npm/hls.js");
script.onload = () => {
    console.log(Hls.isSupported());
}
document.body.appendChild(script);

In both cases, I can see the script being downloaded and showing up in the browser's Debugger pane (F12), but Hls is not defined.

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!