Search code examples
requirejshtml5shiv

Require.js: In require.config how to load js specific to IE?


I am new to require.js. I am using html5shiv for IE polyfill, which execute only in IE.

Now, how to define IE specific condition in require.config ?

require.config({
  paths: {
    jquery: 'libs/jquery',
    html5shiv : 'libs/html5shiv'
  }
});

html5shiv should get loaded only in IE


Solution

  • late to the party perhaps, but you can use bowser its already amd-ready

    require(['bowser'],function(bowser){
        if (bowser.msie && bowser.version < 9) {
            //include your html5shiv/shim/modernizr here
        }
    });
    

    best of luck!