JavaScript How to load jQuery Migrate for jQuery via RequireJS? jquery migrate load

Can I load jQuery migrate via RequireJS? I don't understand how the timing can be handled correctly. See this example:

require([
  'jquery',
  'jqmigrate'
], function ($) {
  if ($.browser.msie) {...}
});

Isn't is possible that jqmigrate will load before jquery? Also, I do not want to keep loading jqmigrate explicitly in every module. Any way to do this in the require.config so it loads jqmigrate automatically when jQuery is required?

Answer:1

using shims worked for me. I did get stuck because i had pluralized shims its; shim

requirejs.config({
    paths: {
        'jquery': '//code.jquery.com/jquery-2.1.4',
        'jquery-migrate': '//code.jquery.com/jquery-migrate-1.2.1'
    },
    shim: {
        'jquery-migrate': { deps: ['jquery'], exports: 'jQuery' },
        'foo': ['jquery']
    }
});
require(['jquery-migrate', './foo'], ($, foo) => {
     console.log('bootstrapped', $, foo);
});
Answer:2

There are a couple of things you will need:

  1. make sure jqmigrate depends on jquery.
  2. you could write a wrapper module that include both, and return jquery, so your require.config could look like:

jquery-wrapper.js:

define(['jquery-src', 'jqmigrate'], function ($) {
  return $;
})

require.config

{
  paths: {
    'jquery-src' : '/path/to/jquery',
    'jqmigrate': '/path/to/jqmigrate',
    'jquery': '/path/to/jquery-wrapper'
  }
}
Answer:3

Does JWPlayer support the file source from soundcloud? <script type="text/javascript" language="javascript"> jwplayer("mainplayer").setup({ playlist: [{ ...

Does JWPlayer support the file source from soundcloud? <script type="text/javascript" language="javascript"> jwplayer("mainplayer").setup({ playlist: [{ ...

I'm using passy's angular-masonry directives to render tiled elements in my app. Unlike a lot of the masonry examples, my bricks don't include images, just static text and layout content rendered ...

I'm using passy's angular-masonry directives to render tiled elements in my app. Unlike a lot of the masonry examples, my bricks don't include images, just static text and layout content rendered ...

Im using datatables and I came across for a self requirements where I want a live table data and I use datatables for this requirements, however Im having an issue when displaying the pulled data from ...

Im using datatables and I came across for a self requirements where I want a live table data and I use datatables for this requirements, however Im having an issue when displaying the pulled data from ...

  1. datatables live records add edit delete

Ok, so I need to trigger an event when specific (let's say number 2) slide is displayed. I've checked this function: $('#myCarousel').bind('slide.bs.carousel', function (e) { console.log($(this));...

Ok, so I need to trigger an event when specific (let's say number 2) slide is displayed. I've checked this function: $('#myCarousel').bind('slide.bs.carousel', function (e) { console.log($(this));...

  1. trigger specific event vba
  2. c# trigger event specific time
  3. trigger event at specific time
  4. jquery trigger specific event
  5. javascript trigger event at specific time
  6. java trigger event at specific time
  7. android trigger event at specific time
  8. specific trigger event