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

128
Views
How to import a web assembly code in html

I am learning the fundamentals of web assembly using rust and I am following this tutorial. It worked fine for all the things except when importing the web assembly javascript code where it gives this error,

Loading failed for the module with source “http://localhost:8000/pkg/hello_wasm.js”.

I tried disabling all the third party extensions and retried it but I am getting the same error.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Hello Wasm!</title>
    <script type="module">
      import init, { add } from './pkg/hello_wasm.js'

      await init() // this loads and instantiates our WASM module
      console.log(add(1, 2)) // this calls our compiled Rust function!
    </script>
  </head>
  <body></body>
</html>


 └── App/
    ├── pkg/
    │   ├── hello_wasm_bg.wasm
    │   ├── hello_wasm.js
    │   ├── some _ other _ files
    │   └── index.html
    └── src/
        └── lib.rs
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have index.html in your pkg folder, so when you import the js file as ./pkg/... it will look for a folder called pkg inside of pkg. Move index.html up a directory (and restart the server from the App folder), or change the import to ./hello_wasm.js for this to work properly.

 └── App/
    ├── index.html
    ├── pkg/
    │   ├── hello_wasm_bg.wasm
    │   ├── hello_wasm.js
    │   └── some _ other _ files
    └── src/
        └── lib.rs
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!