Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
If you're not importing it as a module but just including it through a <script> tag, you can't use the regular file. You'll need to use the UMD file instead. You can either include it from a ...
Answer
#1: Initial revision
If you're not importing it as a module but just including it through a `<script>` tag, you can't use the regular file. You'll need to use the UMD file instead. You can either include it from a CDN (`https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.js`), or download that file, rehost it, and include it in a `<script>` tag. Then you can just call `new Chart()` in a subsequently loaded script. This version of Chart.js has extra code at the beginning to detect how it's being loaded and to run appropriately.