title: Cordova: Device Ready not working
body: <p>I am using Cordova to build mobile apps but for some reason device ready not fired.</p>
  
  <p>Here are some of the codes.</p>
  
  <pre><code>&lt;script type="text/javascript" src="cordova.js"&gt;&lt;/script&gt;
  &lt;script src="./js/jquery-2.1.3.min.js"&gt;&lt;/script&gt;
  &lt;script src="./js/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
   document.addEventListener("deviceready", function(){
        alert("123");
   },true);
  
  function plays() {
    window.HeadsetDetection.detect(function(detected) {    
      window.plugins.insomnia.keepAwake()
                  cordova.plugins.tonegenerator.play(650)
                })
  
    document.addEventListener('deviceready', function() {
      window.HeadsetDetection.registerRemoteEvents(function(status) {
          switch (status) {
              case 'headsetAdded': 
                  window.plugins.insomnia.keepAwake()
                  cordova.plugins.tonegenerator.play(340)
              break;
              case 'headsetRemoved':
                  alert('Please connect to Headset/Earpiece then play.');
              break;
          };
      });
  }, true);
  
  }
  
  
   &lt;a class="btn btn-home" onclick="plays()"&gt;&lt;i class="icon ion-ios-play"&gt;&lt;/i&gt; Play&lt;/a&gt;&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>When I click on Play button sound is playing. 
  As you can see there is some alert box on device ready. Those alert are not firing.</p>
  
  <p>Any advice what am I doing wrong here?</p>
  
  <p>Thanks</p>