Answers.Body: <p>The best practice is to store your .js script in a folder labelled JavaScript inside the .oebps folder, then have your HTML point to that script / directory whenever you need to employ it. I have to confess though that I did not understand most if your question with the 'tiny boxes' and such.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-02T01:20:01.657Z
Answers.LastActivityDate: 2014-07-02T01:20:01.657Z
Answers.UserDisplayName: maxwell
Body: <p>I would like to develop responsive ebooks, and lucky me I found that iBook Author allows to include javascript in the books. This works through inserting the HTML widget in a small box to the text. </p>
  
  <p>What is the best practice when one uses the same javascript code again and again inside the book? What if I would like to use e.g. d3.js several times to create figures? Do I need to insert it every single time to the given page, inside the given widget? Can I reuse parts of the code, store d3.js in some place, so all the widgets can use that piece of code several times on different pages?</p>
  
Tags: <html><apple-books>
Title: Using the same javascript library several times in an ebook
UserDisplayName: Greg
ThreadText: # Using the same javascript library several times in an ebook
  
  (Asked by: username_0 on 2014-07-01)
  
  I would like to develop responsive ebooks, and lucky me I found that iBook Author allows to include javascript in the books. This works through inserting the HTML widget in a small box to the text.
  
  What is the best practice when one uses the same javascript code again and again inside the book? What if I would like to use e.g. d3.js several times to create figures? Do I need to insert it every single time to the given page, inside the given widget? Can I reuse parts of the code, store d3.js in some place, so all the widgets can use that piece of code several times on different pages?
  
  **Tags:** html, apple-books
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-02. Score: 3 | Accepted answer
  
  The best practice is to store your .js script in a folder labelled JavaScript inside the .oebps folder, then have your HTML point to that script / directory whenever you need to employ it. I have to confess though that I did not understand most if your question with the 'tiny boxes' and such.
  
  
  ---
  
  