title: In JS, If two function are called by unload in what order are they processed by the browser
body: <p>I am trying to call <code>newsize(picture_src)</code> after the function <code>resizeimg()</code>.
  It appears that the function <code>newsize(picture_src)</code> is always called first. </p>
  
  <p>The function <code>resizeimg()</code> has to be called first because it sets the <code>sizepic()</code> function that <code>newsize(picture_src)</code> uses to change the image <code>src</code>.</p>
  
  <p>Here's my html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8" /&gt;
      &lt;title&gt;TP n°1 - Mise en place d'une grille responsive&lt;/title&gt;
  
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
  
      &lt;link href="css/reset.css" rel="stylesheet"/&gt;
      &lt;link href="css/style.css" rel="stylesheet"/&gt;
      &lt;script&gt;
              if(window.innerWidth&gt;1200){
                  var sizepic='1200';
              }
              else if(window.innerWidth&lt;1200 &amp;&amp; window.innerWidth&gt;900){
                  var sizepic='990';
              }
              else if(window.innerWidth&lt;990 &amp;&amp; window.innerWidth&gt;768){
                  var sizepic='768';
              }
              else if(window.innerWidth&lt;768 &amp;&amp; window.innerWidth&gt;590){
                  var sizepic='590';
              }
              else if(window.innerWidth&lt;590){
                  var sizepic='petit';
              }
  
      function newsize(picture_src, picture){
                  picture_src.src=='img/'+sizepic+'/'+picture+sizepic+'.jpg';
                  alert(picture_src.src);
      }
      &lt;/script&gt;
  
      &lt;!--[if lt IE 9]&gt;
          &lt;script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"&gt;&lt;/script&gt;
          &lt;script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"&gt;&lt;/script&gt;
      &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
  
      &lt;div class="wrapper"&gt;
  
          &lt;!-- 1ère ligne --&gt;
          &lt;div class="row"&gt;
              &lt;div class="col100"&gt;
                   &lt;div class="row"&gt;
                      &lt;div class="col60 cs100"&gt;
                          &lt;div id='september'class="xs-contenu"&gt;
                              &lt;h1&gt;Experience the web&lt;/h1&gt;
                              &lt;p&gt;&lt;strong&gt;September 2013 Club Theme&lt;/strong&gt;&lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="col40 cs100"&gt;
                          &lt;div class="xs-contenu"&gt;
                              &lt;div id='dv-icon'&gt;
                                  &lt;img src='img/1200/iconchat.jpg'&gt;
                                  &lt;img src='img/1200/icontwitter.jpg'&gt;
                                  &lt;img src='img/1200/iconbasket.jpg'&gt;
                                  &lt;img src='img/1200/iconfacebook.jpg'&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                 &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;!-- 2nde ligne --&gt;
  
  
  
          &lt;!-- 3ème ligne --&gt;
          &lt;div class="row"&gt;
              &lt;div class='col20 cs50'&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col100"&gt;
                          &lt;div class="contenu"&gt;
                              &lt;p class='square'&gt;Design and styled with Ulkit.&lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="col100"&gt;
                          &lt;div class="contenu"&gt;
                              &lt;img onload='newsize(this, 'cube')'src=""/&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>