Help with using a js library

hey! i need help using color.js (https://github.com/luukdv/color.js/) but i dont really know how to use libraries.
GitHub
GitHub - luukdv/color.js: Extract colors from an image (0.75 KB) 🎨
Extract colors from an image (0.75 KB) 🎨. Contribute to luukdv/color.js development by creating an account on GitHub.
6 Replies
Cosy
CosyOP5mo ago
https://codepen.io/CosyXD/pen/QWXwGqM?editors=1111 erm... why is this working on codepen but not on my system
Cosy
CosyOP5mo ago
this is on my pc ^ my functions are undefined i dont understand
No description
glutonium
glutonium5mo ago
show index.html:13
MarkBoots
MarkBoots5mo ago
i don't think you need to load your index.js file with type module. (codepen will work because the js differently loaded) also, it is easier to load libraries in the head section i would do this
<head>
<script src="https://unpkg.com/[email protected]/dist/color.js"></script>
<script src="index.js" defer></script> <!-- defer makes sure everything else is loaded first -->
</head>
<body>
...
</body>
<head>
<script src="https://unpkg.com/[email protected]/dist/color.js"></script>
<script src="index.js" defer></script> <!-- defer makes sure everything else is loaded first -->
</head>
<body>
...
</body>
if this doesn't solve it, please show your real js file (because the error is showing on a different line than in the codepen file), and maybe something else is causing the issue
Cosy
CosyOP5mo ago
No description
Cosy
CosyOP5mo ago
yeah that did it! ty maybe it had something to do with the defer attribute you added i'll look into that thanks yall for helping out
Want results from more Discord servers?
Add your server