2014-12-29 08:20:22 -08:00
# Browser Builds
2015-02-24 06:26:37 -08:00
Bitcore and most official submodules work in the browser, thanks to [browserify ](http://browserify.org/ ) (some modules are not fully compatible with web browsers).
2015-02-23 14:30:25 -08:00
2015-10-21 20:01:52 -07:00
The easiest and recommended way to use them, is via [Bower ](http://bower.io/ ), a browser package manager, and get the release bundles. For example, when building an app that uses `bitcore` and `bitcore-mnemonic` , you do:
2015-02-23 14:30:25 -08:00
2015-02-23 14:32:57 -08:00
```sh
2015-10-21 20:01:52 -07:00
bower install bitcore-lib
bower install bitcore-mnemonic
2015-02-23 14:30:25 -08:00
```
You can also use a `bower.json` file to store the dependencies of your project:
```json
{
"name": "Your app name",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
2015-10-21 20:01:52 -07:00
"bitcore-lib": "^0.13.7",
"bitcore-mnemonic": "^1.0.1"
2015-02-23 14:30:25 -08:00
}
}
```
2015-10-16 09:43:27 -07:00
2015-02-23 14:30:25 -08:00
and run `bower install` to install the dependencies.
After this, you can include the bundled release versions in your HTML file:
2015-10-16 09:43:27 -07:00
2015-02-23 14:30:25 -08:00
```html
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
2015-10-21 20:01:52 -07:00
< script src = "bower_components/bitcore/bitcore-lib.min.js" > < / script >
< script src = "bower_components/bitcore-mnemonic/bitcore-mnemonic.min.js" > < / script >
2015-02-23 14:30:25 -08:00
< / head >
< body >
< script type = "text/javascript" >
2015-10-21 20:01:52 -07:00
var bitcore = require('bitcore-lib');
var Mnemonic = require('bitcore-mnemonic');
2015-02-23 14:30:25 -08:00
// etc...
< / script >
< / body >
< / html >
```
2015-02-24 07:59:36 -08:00
## Building Custom Bundles
2015-10-16 09:43:27 -07:00
If you want to use a specific version of a module, instead of a release version (not recommended), you must run browserify yourself. You can get a minified browser bundle by running the following on the project root folder.
2015-02-23 14:30:25 -08:00
2015-02-23 14:32:57 -08:00
```sh
2015-10-21 20:01:52 -07:00
browserify --require ./index.js:bitcore-lib | uglifyjs > bitcore-lib.min.js
2015-02-23 14:30:25 -08:00
```
2015-10-16 09:43:27 -07:00
2015-02-23 14:32:57 -08:00
```sh
2015-10-21 20:01:52 -07:00
browserify --require ./index.js:bitcore-mnemonic --external bitcore-lib | uglifyjs > bitcore-mnemonic.min.js
2015-02-23 14:30:25 -08:00
```
2015-10-21 20:01:52 -07:00
In many of the modules you can also run the command to build a browser bundle:
```sh
gulp browser
2014-12-29 08:20:22 -08:00
```