How can I import blockstack.js as a script without using a package manager?

Is it possible to have the Blockstack.js as a just a script that we can use

Like just importing it into a HTML file and start using blockstack,js as

blockstack.function(){
something;
}
I love blockstack but I don’t like to use the npm way to do it. And it has some issues in versions also. That’s why this idea.

Regards,
@karanganesan

1 Like

Hey thanks for posting Karan, love that you’re thinking about this.

We’ll share some thoughts on it soon.

Yes! You can download blockstack.js from the dist folder and use it without npm! https://github.com/blockstack/blockstack.js/tree/master/dist

This is how we use it in both our ruby blockstack omniauth strategy and blockstack-android libraries.

I added an issue to update our readme and make this more clear! Thank you for the feedback!!! https://github.com/blockstack/blockstack.js/issues/517

2 Likes

Great :heart:

Looking forward to try it :100:

1 Like

I downloaded the latest version of blockstack.js from the dist folder and tried to include it as a normal .js script from my html code. However, my editor flags over a 100 errors in the blockstack.js file. I haven’t looked at the details of the errors yet, but I am wondering if I need to include any dependencies with blockstack.js

I don’t use npm for blockslack (source: https://github.com/djnicholson/blockslack) I just combine the contents of https://raw.githubusercontent.com/blockstack/blockstack.js/v18.2.1/dist/blockstack.js with the rest of the Javascript that I minify.

The JavaScript does use ES6 features, so you may see errors if your editor/browser does not support that. You could transpile it to support older browsers, but there is not much point because the blockstack rendered JavaScript used during authentication also uses ES6.

see this;

and this;

Thanks for sharing. It really makes things clear for me.