How to use script tags to introduce the opensea-js library in pure HTML/JS?
P粉491421413
2023-09-02 16:44:01
<p>I want to use opensea-js in my html/js project, but their source code is only published on github and npm.
https://github.com/ProjectOpenSea/opensea-js</p>
<p>How can I use this in normal html? (Not a page based on node.js)</p>
<p>I found something here</p><p>
https://www.jsdelivr.com/package/npm/opensea-js</p>
<p>But after I put this code into my html it doesn't work. </p>
<pre class="brush:php;toolbar:false;"><script src="https://cdn.jsdelivr.net/npm/@bthn/opensea-js@4.0.1/lib/index .min.js"></script></pre></p>
I strongly recommend using babel or webpack. No matter which one you choose, there's a steep learning curve, so you should start using one while you're at it rather than developing bad habits later.
Using babel/webpack has many advantages over using CDN. Refer to this article (it also works with babel): https://webpack.js.org/concepts/why-webpack/