Skip to content

Commit 3ef2d6f

Browse files
committed
Merge pull request #315 from bitcoinjs/browserdocs
README: improve browser setup advice
2 parents 18fb33d + 642315e commit 3ef2d6f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

README.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,38 @@ If you are looking for the original, it is tagged as `0.1.3`. Unless you need it
4444

4545
var bitcoin = require('bitcoinjs-lib')
4646

47-
From the repo:
4847

49-
var bitcoin = require('./src/index.js')
48+
### Browser
5049

50+
If you're familiar with how to use browserify, ignore this and proceed normally.
51+
These steps are advisory only and allow you to use the API to its full extent.
5152

52-
### Browser
53+
[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps.
54+
55+
From your repository, create a `foobar.js` file
56+
57+
``` javascript
58+
var foobar = {
59+
base58: require('bs58'),
60+
bitcoin: require('bitcoinjs-lib'),
61+
ecurve: require('ecurve'),
62+
BigInteger: require('bigi'),
63+
Buffer: require('buffer')
64+
}
65+
66+
module.exports = foobar
67+
```
5368

54-
From the repository: Compile `bitcoinjs-min.js` with the following command:
69+
Each of these included packages are seperate to `bitcoinjs-lib`, and must be installed separately.
70+
They are however used in the bitcoinjs-lib public API.
5571

56-
$ npm run-script compile
72+
Using browserify, compile `foobar.js` for use in the browser:
5773

58-
From NPM:
74+
$ browserify foobar.js -s foobar > foobar.js
5975

60-
$ npm -g install bitcoinjs-lib browserify uglify-js
61-
$ browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js
76+
You will then be able to load `foobar.js` into your browser, with each of the dependencies above accessible from the global `foobar` object.
6277

63-
After loading this file in your browser, you will be able to use the global `bitcoin` object.
78+
**NOTE**: See our package.json for the currently supported version of browserify used by this repository.
6479

6580

6681
## Examples

0 commit comments

Comments
 (0)