Skip to content
Jacob Burden edited this page Aug 2, 2016 · 14 revisions

CDN

OpenShare is extremely easy to get set up and rocking with. The fastest way to get started is to include a link from the CDN in a script tag just before your closing body tag.

<!doctype html>
<body>
  <script src='https://cdn.rawgit.com/OpenShare/openshare/master/dist/openshare.js'></script>
</body>

Download

The CDN doesn't guarantee up time. If you want to be safe, you can download the minified openshare.js file directly and include in a script tag just before your closing body tag.

<!doctype html>
<body>
  <script src='your-folder/openshare.js'></script>
</body>

NPM

The best way to install OpenShare is through npm:

npm install openshare --save

and then require it in your js:

var OpenShare = require('openshare')

The OpenShare module will return an object containing Share and Count functions which can be called like so, read more about the JavaScript API.

var shareNode = new OpenShare.share(options, element)
var countNode = new OpenShare.count(options)

If you are not using the JavaScript API (only the Data Attribute API) then all you need to do is:

require('openshare') // data attribute API just works 🚀

NPM (custom builds)

You can also require just the parts of OpenShare that you need. For example if you only need to create share nodes:

var share = require('openshare/share')
var shareNode = new share(options, element)

Or if you only need to create count nodes:

var count = require('openshare/count')
var countNode = new count(options)

Using npm but not a transpiler (like Babel)?

We include a pre-transpiled and minified ES5 version of OpenShare with the npm module.

var OpenShare = require('openshare/dist/openshare')