I am trying to use JQuery in my block functions, but I get an error saying JQuery not found. I tried google and some suggested to add it to local.xml but I think Magento2 does not have local.xml.

Can anyone help me on how to enable JQuery in Magento2?


1 Answer 1


You should use requirejs to manage/resolve dependencies in JS code. For example

  ['jquery'], // list of dependencies
  function($) {
     //put your code that use jquery here

See documentation for more detais

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.