I am using require JS and want to know the best method to use a CDN version of jQuery. I hear the 1.7 version is “AMD” which is supposed to help but can’t find a straight example. Hope some RequireJS gurus can help me out.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
jQuery 1.7 registers itself as an AMD module by the name of ‘jquery’, so you need to create a mapping for ‘jquery’ using the paths config:
Note however that RequireJS loads modules asynchronously and out of order, so if you have jQuery plugins you want to use that are not wrapped in
define(['jquery'], function ($){ /* plugin code goes here */ });calls, the plugin could execute before jQuery is loaded.See the require-jquery project’s README on ways to deal with files that depend on jQuery but do not wrap themselves in
define()calls.