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


#1

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


#2

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

We’ll share some thoughts on it soon.


#3

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


#4

Great :heart:

Looking forward to try it :100:


#5

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


#6

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.


#7

see this;

and this;


#8

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