Recently, one of our clients started to get $.widget is not a function JS error on their Magento 2 store and as a result, customers weren’t able to complete their checkout.

The error was present on Minicart, Product view page, and Checkout page and even changing to default Magento 2 template did not fix the issue.  Eventually, I found that the issue was with Magento JS merging and I was able to fix the issue by making the following changes:

Merge all javascript files:

In Backend go to:

Stores -> Configuration -> Advanced -> Developer -> JavaScript Settings

Activate:

  • Enable JavaScript Bundling
  • Merge JavaScript Files
  • Minify JavaScript Files (Optional)

Deploy the static files

bin/magento setup:static-content:deploy

Clear cache under System -> Cache Management

  • In Additional Cache Management region choose the Button Flush CSS/Javascript Cache
  • And Flush Magento Cache afterwards

Now clear Cache in Browser and reload. Everything should be back to normal now.