title: Load Select2 jQuery plugin immediately on load RequireJS
body: <p>I have a RequireJS setup that loads the <a href="http://ivaynberg.github.io/select2" rel="nofollow">Select2</a> jQuery plugin.</p>
  
  <p>I have an issue however that means on page load, the browser default select input is shown for a few seconds, and then swapped out for the advanced Select2 input presumably as RequireJS is loading my scripts asynchronously.</p>
  
  <p>Is there a way I can avoid this without having to include the script in the HTML?</p>
  
  <p>This is my RequireJS setup:</p>
  
  <pre><code>require.config({
  baseUrl: '/assets/js',
  paths: {
      jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min',
      async: 'libs/async',
      modernizr: 'libs/modernizr-custom',
      jqueryUI: 'libs/jquery-ui.min',
      bootstrap: 'libs/bootstrap.min',
      select2: 'libs/select2.min',
  },
  shim: {
      'select2': {
          deps: ['jquery'],
          exports: 'Select2'
      },
      'bootstrap': {
          deps: ['jquery'],
          exports: 'Bootstrap'
      },
      'jqueryUI': {
          deps: ['jquery'],
          exports: 'jQueryUI'
      },
  }
  });
  
  requirejs(["app/polyfills"]);
  requirejs(["app/filter"]);
  requirejs(["app/select"]); // Select2 plugin trigger
  requirejs(["app/datepicker"]);
  requirejs(["app/popover"]);
  requirejs(["app/dropdown"]);
  requirejs(["app/tooltip"]);
  requirejs(["app/layout"]);
  requirejs(["app/menu"]);
  requirejs(["app/toggles"]);
  </code></pre>
  
  <p>And this is the actual script:</p>
  
  <pre><code>define(['select2'], function(Select2) {
  
      var app = {};
  
      app.select = (function(){
          var module = {};
  
          module.init = function(){
  
              $(".select-advanced").select2({
                  width: 'off',
                  dropdownAutoWidth: 'true',
              });
          };
  
          return module;
      })();
  
      $(document).ready(function(){
          app.select.init();
          console.log('select');
      });
  
  }); 
  </code></pre>