title: Why is console.log not a function in Shiny for R?
body: <p>I include <code>JavaScript</code> in <code>Shinys ui.R</code> like this:</p>
  
  <pre><code>tags$body(tags$script(src="someJs.js"))
  </code></pre>
  
  <p>Within my <code>someJs.js</code> I have a function</p>
  
  <pre><code>function someFunc1() {
      ....;
  }
  
  ... some more code ...
  
  console.log(variable1);
  </code></pre>
  
  <p>The <code>console.log</code> is <strong>outside</strong> of the function <code>soemFunc1()</code>. 
  When I start the App and have a look at the console, I get</p>
  
  <blockquote>
    <p>console.log() is not a function. </p>
  </blockquote>
  
  <p>Why is that?</p>
  
  <p>I also load <code>d3</code> in the head <code>tags$head(tags$script(src="d3.v3.min.js"))</code>.
  When I try <code>d3.select...</code> in the console, I also get </p>
  
  <blockquote>
    <p>d3 is not a function. </p>
  </blockquote>
  
  <p>However, I use <code>d3</code> in my app for styling. </p>
  
  <p>What is <code>Shiny</code> doing with the <code>js</code>. Is there an object where it attaches everything to?!</p>
  
  <p>Here a an example, easy to reproduce.</p>
  
  <p><code>ui.R</code> </p>
  
  <pre><code>library(shiny)
  
  shinyUI(fluidPage(
      tags$head(tags$script(src="https://d3js.org/d3.v3.min.js")),
      tags$head(tags$script(src="test.js")),
              mainPanel(
                      tags$div(id = "test", "test test test")
              )
      )
  </code></pre>
  
  <p>)</p>
  
  <p><code>server.R</code></p>
  
  <pre><code>library(shiny)
  
  shinyServer(function(input, output) {
  
  })
  </code></pre>
  
  <p>create a <code>www</code> folder in the same directory where <code>server.R</code> and <code>ui.R</code> are and save a <code>js</code> file with the name <code>test.js</code> with the following content:</p>
  
  <pre><code>console.log("This will cause error")
  </code></pre>
  
  <p>Now, go ahead and open the console.
  It says </p>
  
  <blockquote>
    <p>console.log() is not a function</p>
  </blockquote>
  
  <p>Try type into the console of the browser <code>d3</code>. It says </p>
  
  <blockquote>
    <p>d3 is not a function. </p>
  </blockquote>