title: How can I make sure RequireJS in Magento 2 loads jQuery before loading other scripts? I found that nesting requires solves this
body: <p>I'm trying to load a lazy loader plugin which requires jQuery to function.
  If I write my script as such:</p>
  
  <pre><code>require([
          "jquery",
          "ScandiLazy",
      ], function ($) {
          jQuery('.category-products .lazy').lazy();
      });
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>"jquery.lazy.min.js:43 Uncaught TypeError: Cannot read property 'fn' of undefined",
  </code></pre>
  
  <p>Followed by:</p>
  
  <pre><code>Uncaught TypeError: jQuery(...).lazy is not a function
  </code></pre>
  
  <p>which is an error through because jQuery is not loaded.</p>
  
  <p>But if I nest the requires:</p>
  
  <pre><code> require([ "jquery"], function ($) {
          require([ "ScandiLazy"], function ($) {
              jQuery('.category-products .lazy').lazy();
          });
      });
  </code></pre>
  
  <p>Then it works perfectly.</p>
  
  <p>But it feels wrong to nest the requires in order to make it work, is this actually a correct way to do this?</p>
  
  <p>If this is incorrect, what's a way to make absolute sure jQuery is loaded before the ScandiLazy lazy load plugin loads?</p>