What is MIME type "application/wasm"?
A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.
application/wasm designates files that contain WebAssembly code. It informs browsers that the file holds low-level, compiled instructions, enabling near-native speed in web apps.WebAssembly was created to boost performance for browser-based tools. It complements JavaScript by handling compute-intensive tasks.
- Main use: Running performance-critical modules directly in the browser.
- Other uses: Supporting cross-language development by allowing compiled languages like C, C++, or Rust to be used in web projects.
- Practical details: The standard binary format uses the WASM file, while the textual format used for development and debugging uses the WAST file.
Associated file extensions
Usage Examples
HTTP Header
When serving content with this MIME type, set the Content-Type header:
Content-Type: application/wasm
HTML
In HTML, you can specify the MIME type in various elements:
<a href="file.dat" type="application/wasm">Download file</a>
Server-side (Node.js)
Setting the Content-Type header in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.setHeader('Content-Type', 'application/wasm');
res.end('Content here');
}).listen(3000);
Associated file extensions
FAQs
Why do I get a "TypeError: Incorrect response MIME type" when loading a .wasm file?
This error occurs because the web server is not sending the correct Content-Type header. Browsers strictly require the header to be application/wasm for streaming compilation; if the server defaults to application/octet-stream or text/plain, the browser will block execution for security reasons.
How do I configure Apache to serve WebAssembly files correctly?
You need to add the MIME type directive to your configuration or .htaccess file. Add the line AddType application/wasm .wasm to ensure Apache serves files with the .wasm extension using the correct content type.
How do I enable application/wasm in Nginx?
You should update your mime.types file, which is usually located in /etc/nginx/. Add the line application/wasm wasm; inside the types block, then reload Nginx to apply the changes.
How do I add the WebAssembly MIME type to IIS?
In Internet Information Services (IIS), you must explicitly add a MIME mapping in your web.config file. Insert <mimeMap fileExtension=".wasm" mimeType="application/wasm" /> inside the <staticContent> section to allow IIS to serve these files.
Is application/wasm used for .wast files?
No, application/wasm is specifically for the binary .wasm format that browsers execute. The .wast extension refers to WebAssembly Text, a human-readable representation used for debugging, which typically uses a text-based MIME type or is converted to binary before deployment.
Can I open an application/wasm file to view the code?
Not directly in a text editor, as application/wasm files contain compiled binary data. To view the source logic, you must use a disassembler tool (often found in browser developer tools) to convert the binary back into the readable text format.
Does serving files as application/wasm improve performance?
Yes, using the correct MIME type allows browsers to use streaming compilation. This means the browser can start compiling the WebAssembly code into machine code while the file is still downloading, significantly reducing the startup time for your application.
General FAQ
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.
MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.
How do I find the MIME type for a file?
You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.
Why are multiple MIME types listed for one extension?
Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.