| CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Sun, 16 Oct 2022 09:37:19 GMT
access-control-allow-origin: *
etag: W/"634bd0cf-27a1"
expires: Fri, 26 Dec 2025 10:35:20 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 66BF:2D64E0:520F8F:5B79F0:694E6290
accept-ranges: bytes
age: 0
date: Fri, 26 Dec 2025 10:25:20 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210076-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1766744721.658362,VS0,VE199
vary: Accept-Encoding
x-fastly-request-id: bee6d17dfc80481a7ecb13ee10c235370545a1b5
content-length: 3129
Browserify
Browserify lets you require('modules') in the browser by bundling up all of your dependencies.
Install
use Browserify from the Command Line
Hello World With Browserify
Bundle up your first module
Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that uses require in the same way that you would use it in Node.
Here is a tutorial on how to use Browserify on the command line to bundle up a simple file called main.js along with all of its dependencies:
main.js
var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; console.log(unique(data));
Install the uniq module with npm:
npm install uniq
Now recursively bundle up all the required modules starting at main.js into a single file called bundle.js with the browserify command:
browserify main.js -o bundle.js
Browserify parses the AST for require() calls to traverse the entire dependency graph of your project.
Drop a single <script> tag into your html and you're done!
<script src="bundle.js"></script>
More
- Read the Browserify Handbook
- Use many of the tens of thousands of modules on NPM in the browser
- Use watchify, a browserify compatible caching bundler, for super-fast bundle rebuilds as you develop.
- Use tinyify for optimized, tree-shaked bundles in production environments.
- Use --debug when creating bundles to have Browserify automatically include Source Maps for easy debugging.
- Check out tools like Beefy or run-browser which make automating browserify development easier.
- process.nextTick(), __dirname, and __filename node-isms work
- Get browser versions of the node core libraries events, stream, path, url, assert, buffer, util, querystring, http, vm, and crypto when you require() them
Community
Join irc.freenode.net/#browserify for help, or tweet @browserify.
Who Uses Browserify
here are some things people have said
Browserify is elegant and fast. It makes frontend development fun again! That's why we used it to build Yahoo's new HTML5 video player. - feross, developer on the Video team at Yahoo.
At Mapbox we build our website and JavaScript API with Browserify. It makes the structure and modularity of our code rock. - tmcw, developer at Mapbox.
Browserify does exactly what it says it does and it does it well. I'm glad it exists. - zpao, developer on the React team at Facebook.
Browserify radically sped up builds, simplified builds and encouraged modularity. - terinjokes, developer at CloudFlare.
View more at the Browserify in the wild page.
