title: Using requireJS within Wordpress
body: <p>I'm setting up a way for me to keep my preferred requireJS way of working and integrate this with Wordpress. </p>
  
  <p>The big issue being how then to load jquery. Wordpress loads jQuery via wp_enqueue_script which needs to remain that way as some Wordpress plugins I regularly use need jquery to be added that way. I don't then want to load a second version of jQuery within my requireJS setup. So, after some looking around this is what I've come up with:</p>
  
  <p>templates/footer.php</p>
  
  <pre><code>&lt;script&gt;
  if (typeof jQuery === 'function') {
      define( 'jquery', function () { return jQuery; } );
  }
  
  require(['/assets/js/sample-common.js'], function (common) {
     require(['sample-bootstrapper']);
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Which sees if jQuery has already been added to the page, if it has been then it sets it as the module value.</p>
  
  <p>My question is should I then just leave jquery to be in the global namespace, or follow these instructions:</p>
  
  <p><a href="http://requirejs.org/docs/jquery.html#noconflictmap" rel="noreferrer">http://requirejs.org/docs/jquery.html#noconflictmap</a></p>
  
  <p>The problem with the above is I will probably need to include jquery plugins that aren't AMD compatible, is it worth the effort to make them AMD compatible or another solution I thought about was removing the true from the noConflict declaration which keeps the 'jQuery' in the global namespace allowing the plugins to function.</p>
  
  <p>This is less of a question and more of a call for best practice advice. And any would be much appreciated!</p>
  
  <p>Thanks!</p>