0

I was facing issues after upgrading to jQuery 2.0 My application stopped working on IE8 and less. The application currently use Require.JS to modularise my code.

I found a very nice solution here for conditional check of the browser. But my application also uses optimisation described here for minifying the code. So I have an app.build.js which looks like the following:

({
appDir:         '../',
baseUrl:        'js/',
dir:            '../../v3-build',
locale:         'en-us',
paths: {
    'modernizr':                'libs/modernizr-2.5.3',
    'jQuery':                   'libs/jquery/jquery-2.0.0',
    'underscore':               'libs/underscore-1.4.4',
    'backbone':                 'libs/backbone-0.9.9',
    'bootstrap':                'libs/bootstrap/bootstrap'        

    // Application - bootstrap for frontend app
    'application':              'application'
},
shim: {
    'jQuery': {
        exports:                '$'
    },

    'underscore': {
        deps:                   ['jQuery'],
        exports:                '_'
    },

    'backbone': {
        deps:                   ['jQuery', 'underscore'],
        exports:                'Backbone'
    },

    'application':              ['jQuery']
},
optimize:                   'uglify2',
modules:        [
    {
        name:       'main'
    }
]

})

Now how do I add check for jquery path here?

2
  • 1
    Why don't you just use jQuery 1.9 so you get the IE support you require? It makes no sense to ensure the application runs against multiple versions of assets. Commented May 16, 2013 at 18:25
  • Yeah I know. This was the first solution that hit me. But just figuring out if there is a way to achieve this Commented May 16, 2013 at 18:27

1 Answer 1

2

If you want to decide jQuery version at runtime then you cannot include it in the bundle that r.js creates. You will need to tell the optimizer to leave it out by using the special "empty:" directive, for example:

paths: {
    jquery: "empty:"
}

Not sure you're saving much bandwidth for all this trouble, but I guess if you give them a CDN path at runtime that should help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.