Free JS sample files
JavaScript source code, as loaded by browsers and run by Node.js. Download valid JS test files in 4 exact sizes, from 1 KB to 1 MB, each with a checksum.
- Extension
- .js
- MIME type
- text/javascript
- Kind
- Text
- Category
- Code
JS files by size
Every file below is a valid JavaScript source file file of exactly the stated size. Open a file's page for its checksum and contents, and to preview it in your browser before downloading.
| File | Size | Contents | Download |
|---|---|---|---|
| 1 KB JS samplesample-js-1kb.js | 1 KB1,024 bytes | Array entries: 4 | Download JS |
| 10 KB JS samplesample-js-10kb.js | 10 KB10,240 bytes | Array entries: 81 | Download JS |
| 100 KB JS samplesample-js-100kb.js | 100 KB102,400 bytes | Array entries: 833 | Download JS |
| 1 MB JS samplesample-js-1mb.js | 1 MB1,048,576 bytes | Array entries: 8,427 | Download JS |
What is a JS file?
A .js file contains JavaScript, the programming language of the web. Browsers download and execute it, and runtimes such as Node.js, Deno and Bun run it on servers.
The language is standardised as ECMAScript, with a new edition each year.
How to recognise a JS file
No signature bytes. JS files are identified by parsing their content.
| Extension | .js |
|---|---|
| MIME type | text/javascript |
| Standard | ECMA-262 (ECMAScript) |
| MIME type | text/javascript, per RFC 9239 |
| Encoding | UTF-8 |
| Module systems | ECMAScript modules and CommonJS |
What to test for
These are the behaviours that most often go wrong when software handles JS files.
- The old types application/javascript and application/x-javascript are obsolete; text/javascript is the registered type.
- Never execute an uploaded script. Treat .js uploads as text to be stored or analysed.
Strengths of JS
- Runs in every browser with no build step required.
- One language for browsers, servers and tooling.
Limitations of JS
- A single syntax error stops the whole file from running.
- Large scripts delay page interactivity while they parse and execute.
Typical uses of JS test files
- Testing bundlers and minifiers with large inputs
- Checking syntax highlighters and editors
- Testing static asset delivery and caching
Software that opens JS
- All web browsers
- Node.js, Deno and Bun
- esbuild, webpack, Rollup and Terser
Specifications
Related
JS sample files: questions
- Does the sample script do anything when loaded?
- No. It defines an array and two functions and has no side effects.
- What is the MIME type of a JS file?
- The MIME type is text/javascript. The file extension is .js.
- Is a sample JS file the same as a dummy or example JS file?
- Yes. Sample, test, dummy and example JS files are different names for the same thing: a JS file with known contents that stands in for a real one. Any file on this page will do wherever a tutorial or a test plan asks for a dummy JS file.