title: Possible to load Leaflet on external JS file?
body: <p>I'm new to Leaflet and was setting it up following the tutorials, which I had no problem to load the map.
  The problem starts when I try to run the script via an external JS file instead of pasting the script inside a HTML tag. So right now I cannot get it to work like this:
  HTML:</p>
  
  <pre><code>&lt;head&gt;
      &lt;link rel="stylesheet" type="text/css" href="leaflet/leaflet.css"/&gt;
      &lt;script type="text/javascript" src="leaflet/leaflet.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" type="text/css" href="src/style.css"/&gt;
      &lt;script type="text/javascript" src="src/javascript.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="mapid"&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>var mymap = L.map('mapid').setView([51.505, -0.09], 13);
  
  document.getElementById("mapid").onload = function loadMap(){
      L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlvZ204MDAiLCJhIjoiY2o5aGRxY3B5MGdyZTMzczJvNm95NHAxeSJ9.6M_vVT8BcyJay_acp-eEXA', {
          attribution: 'Map data &amp;copy; &lt;a href="http://openstreetmap.org"&gt;OpenStreetMap&lt;/a&gt; contributors, &lt;a href="http://creativecommons.org/licenses/by-sa/2.0/"&gt;CC-BY-SA&lt;/a&gt;, Imagery © &lt;a href="http://mapbox.com"&gt;Mapbox&lt;/a&gt;',
          maxZoom: 18,
          id: 'mapbox.streets',
          accessToken: 'your.mapbox.access.token'
      }).addTo(mymap);
  };
  </code></pre>
  
  <p>On JS file I tried to load it without the onLoad() of the div element and tried with it as you can see on the example, but none of them worked.
  Is it even possible to load the leaflet map like this?</p>
  
  <p>Thank you for your time</p>