I’m using Require JS in my project which is loading jQuery and some other JavaScript files that are relevant for the entire site and all browsers.
However, I need to use some conditional jQuery on Internet Explorer 7 & 8, I’ve tried putting this in the head of the page and the script doesn’t seem to be able to find jQuery, I’m presuming this is because it’s getting loaded before jQuery.
<script data-main="/@ViewBag.ScriptsFolder/main" src="/scripts/require.js" type="text/javascript"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="/Scripts/ie.js"></script>
<![endif]-->
Is there any way to rectify this? I’m also trying to load Selectivizr in this way which isn’t working because of the same problem.
Thanks
You could use a conditional IE-specific class on the
htmlelement, then checking for it and loading the IE dependencies inside your existingmainscript. So, the top of the document would look like:And then inside
main.js, you could use:You can’t use the method you’ve described because require.js looks for a single
data-mainattribute to specify the ‘entry point’ – any subsequent calls torequireshould be done in Javascript.