javascripthtmlblockchainethereumopensea

How to include opensea-js through a script tag in vanilla html/js?


I want to use opensea-js in my html/js project, but their source is published on github and npm only. https://github.com/ProjectOpenSea/opensea-js

How can I use it in a normal html? (not pages based on node.js)

I found something here
https://www.jsdelivr.com/package/npm/opensea-js

But it doesn't work after I put this code in my html.

<script src="https://cdn.jsdelivr.net/npm/@bthn/opensea-js@4.0.1/lib/index.min.js"></script>

Solution

  • I highly recommend using babel or webpack. There's a steep learning curve to either one, so you should get used to one of them while you're still learning, not when you've gotten into bad habits.

    There are a number of advantages of babel/webpack over using CDNs. See this article (it also applies to babel): https://webpack.js.org/concepts/why-webpack/