Skip to content

Commit 16b517b

Browse files
committed
README: update browser setup advice
1 parent 41da79c commit 16b517b

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,33 @@ From the repo:
5252

5353
### Browser
5454

55-
From the repository: Compile `bitcoinjs-min.js` with the following command:
55+
If your are familiar with how to use browserify, ignore this and proceed normally.
56+
These steps are advisory only and allow you to use the `bitcoinjs-lib` to its full extent.
5657

57-
$ npm run-script compile
58+
[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps.
5859

59-
From NPM:
6060

61-
$ npm -g install bitcoinjs-lib browserify uglify-js
62-
$ browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js
61+
From your repository, create a `bitcoin.js` file
6362

64-
After loading this file in your browser, you will be able to use the global `bitcoin` object.
63+
``` javascript
64+
var bitcoin = {
65+
base58: require('bs58'),
66+
ecurve: require('ecurve'),
67+
BigInteger: require('bigi'),
68+
Buffer: require('buffer')
69+
}
70+
71+
var bitcoinjs = require('bitcoinjs-lib')
72+
for (var a in bitcoinjs) bitcoin[a] = bitcoinjs[a]
73+
74+
module.exports = bitcoin
75+
```
76+
77+
Then, using browserify, compile `bitcoin.js` for use in the browser:
78+
79+
$ browserify bitcoin.js -s bitcoin > dist/bitcoin.js
80+
81+
You will then be able to load `dist/bitcoin.js` into your browser, with each of the dependencies above accessible from the global `bitcoin` object.
6582

6683

6784
## Usage

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"files": "test/*.js"
6262
},
6363
"scripts": {
64-
"compile": "browserify ./src/index.js -s bitcoin | uglifyjs > bitcoinjs-min.js",
6564
"coverage": "istanbul cover _mocha -- test/*.js",
6665
"coveralls": "npm run-script coverage && coveralls < coverage/lcov.info",
6766
"integration": "mocha --reporter list test/integration/*.js",

0 commit comments

Comments
 (0)