We are launching a Magento 2.1.3 site, and finding that the site will sometimes load all of its Javascript components and dependencies properly, but sometimes fails to load, in which case a slider is not displayed and the console log shows error messages such as "Uncaught TypeError: $(...).swMegamenu is not a function".

How would we go about troubleshooting and resolving the source of these issues?

  • hope fully their might be a JQuery conflict.Try to short out the conflict. – Mujahidh Jan 13 '17 at 3:57
  • Please post your js code. – Rakesh Jesadiya Jan 13 '17 at 5:12
  • The relevant code causing the error I included is: <script type="text/javascript"> require([ 'jquery', 'Smartwave_Megamenu/js/sw_megamenu' ], function ($) { $(".sw-megamenu").swMegamenu(); }); </script> – Gordon Krauthamer Jan 13 '17 at 14:05
  • We're observing today that the site will load the components on a normal reload, but not on a hard reload. – Gordon Krauthamer Jan 13 '17 at 14:11
  • Also, the problems seem to only occur in Magento production mode, not developer mode. – Gordon Krauthamer Jan 13 '17 at 15:17

Hope fully their might be a JQuery conflict.Try to short out the

You can assign a variable.You should add the below line of code where swMegamenu located in.

var jq = jQuery.noConflict();

and use the variable jq instead of $ like jq(...).swMegamenu

Hope fully this might help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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