I am new to libraries and did not know exactly how to word this, so I apologize if this is a duplicate. A quick answer would be lovely because I am creating a product for a client and we are meeting in just a few hours. Anyways let me further explain the question.

Let's use <script src='./js/d3.min.js'></script> as an example. I could add this line to my HTML and then add <script> d3.somecode </script> and all works. But if I go to my file main.js which is prefered and add that same line, it says d3 was used before being defined because my main.js does not see the library. My question is how to use this library in my other javascript file. How am I supposed to use libraries besides using <script> in HTML? Thanks for any help!

有帮助吗?

解决方案

Make sure the line:

<script src='./js/d3.min.js'></script>

comes before the main.js:

<script src='./js/main.js'></script>

on your html document.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top