I am trying to not rely on the basic code as follows in my file:
<script src="//d3js/d3.v3.min.js"></script>
I am trying to include the d3 library in my file structure. I have created a "libs" file in my project. Here is the link to the page to download the d3 library: My question is after downloading the necessary files from github, do I simply create a d3 folder in my libs folder and place the files there? If so, do I reference a specific file or just the folder?
I am trying to not rely on the basic code as follows in my file:
<script src="//d3js/d3.v3.min.js"></script>
I am trying to include the d3 library in my file structure. I have created a "libs" file in my project. Here is the link to the page to download the d3 library: https://github./d3/d3 My question is after downloading the necessary files from github, do I simply create a d3 folder in my libs folder and place the files there? If so, do I reference a specific file or just the folder?
Share Improve this question asked Jul 28, 2016 at 14:05 Martin GreenMartin Green 371 gold badge2 silver badges6 bronze badges2 Answers
Reset to default 2There are a few different ways of importing other people's code. You could, as you suggested, just download the latest release and copy the d3.js
or d3.min.js
into a lib/
directory, then import it like so:
<script src="lib/d3.min.js"></script>
Alternatively, if you're using a package manager like npm
or bower
, you could just install it using that, as remended in the README. There's also a resource showing how you could use a bundler like Rollup to package D3 with all of your other libraries.
You must include your local copy of D3 like so:
<script src="libs/d3.v3.min.js"></script>
No need to create a separate folder if you'll use just D3. If you need other dependencies use like this:
<script src="libs/d3/d3.min.js" charset="utf-8"></script>
<script src="libs/d3/topojson.v1.min.js"></script>
<script src="libs/d3/d3-queue.v2.min.js"></script>