title: AngularJS app does not load on iPad / iPhone Safari (works only after page refresh / second load and afterwards)
body: <p>I have a really weird issue with my AngularJS app on iPad / iPhone safari.</p>
  
  <p>The issue occurs only of first load (after clearing history / website data).</p>
  
  <p>The issue that the application wont start at all - I get a white page and the console (from MacBook develop tools) is full with errors,</p>
  
  <p>Sometimes I'm getting lots of </p>
  
  <pre><code>TypeError: undefined is not an object (evaluating 'd.module')
  ReferenceError: Can't find variable: angular
  TypeError: undefined is not an object (evaluating 'd.$$minErr')
  ReferenceError: Can't find variable: angular
  TypeError: undefined is not an object (evaluating 't.noop')
  ReferenceError: Can't find variable: angular
  ReferenceError: Can't find variable: angular
  ...
  </code></pre>
  
  <p>Sometimes I'm getting <code>Error: $injector:unpr</code> - <code>Unknown Provider</code></p>
  
  <p>And sometimes <code>Error: $injector:nomod</code> - <code>Unknown Provider</code></p>
  
  <p><strong>But if I hit page refresh after getting the white page / errors - all works just fine.</strong></p>
  
  <p>This is part of the third party js libs/plugins I include on my index.html</p>
  
  <pre><code>&lt;script src="resources/plugins/head.load.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/plugins/modernizr-custom.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/jquery/jquery-2.1.0.min.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/angular/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/lib/angular/angular-resource.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/lib/angular/angular-route.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/lib/angular/angular-animate.min.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/angular-translate/angular-translate.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/lib/angular-translate/angular-translate-loader-static-files.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/angular-ui/ui-bootstrap-custom-tpls-0.14.1.min.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/ng-table/ng-table.min.js"&gt;&lt;/script&gt;
  
  &lt;script src="resources/lib/file-upload/ng-file-upload-shim.min.js"&gt;&lt;/script&gt;
  &lt;script src="resources/lib/file-upload/ng-file-upload.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I'm really lost here...</p>
  
  <hr>
  
  <p><strong>Another thing:</strong> I have noticed on my Mac (Resources->Scripts) that if I open a file, lets say Resources->Scripts->FileNameOne.js the content is actually of another file FileNameTwo.js ??? is it a flaw of the dev tools of the Mac that confuses the names/content or can it be related to the problem???</p>
  
  <p>Any Ideas?</p>
  
  <hr>
  
  <p><strong>Here is the complete solution with Grunt</strong></p>
  
  <p>Content of the <em>Gruntfile.js</em></p>
  
  <pre><code>'use strict';
  module.exports = function(grunt){
      grunt.initConfig({
        concat: {
          dist: {
            src: ['WebContent/resources/plugins/head.load.min.js', 'WebContent/resources/plugins/modernizr-custom.js',
                  'WebContent/resources/lib/jquery/jquery-2.1.0.min.js', 
                  'WebContent/resources/lib/angular/angular.min.js', 'WebContent/resources/lib/angular/angular-resource.min.js', 'WebContent/resources/lib/angular/angular-route.min.js', 'WebContent/resources/lib/angular/angular-animate.min.js',
                  'WebContent/resources/lib/angular-translate/angular-translate.min.js', 'WebContent/resources/lib/angular-translate/angular-translate-loader-static-files.js',
                  'WebContent/resources/lib/angular-ui/ui-bootstrap-custom-tpls-0.14.1.min.js',
                  'WebContent/resources/lib/ng-table/ng-table.min.js',
                  'WebContent/resources/lib/websockify/util.js', 'WebContent/resources/lib/websockify/base64.js', 'WebContent/resources/lib/websockify/websock.js',
                  'WebContent/resources/lib/file-upload/ng-file-upload.min.js', 
                  'WebContent/resources/js/services/*',
                  'WebContent/resources/js/services/dialogs/*',
                  'WebContent/resources/js/controllers/*',
                  'WebContent/resources/js/directives/*',
                  'WebContent/resources/plugins/*'],
            dest: 'dist/myWebAppInOneFile.js',
          },
        },
      });
      grunt.loadNpmTasks('grunt-contrib-concat');
      grunt.registerTask('default', ['concat']);
  };
  </code></pre>
  
  <p>Then just call <em>grunt</em> from the relevant folder and you'll get your file</p>