Question: uncaught referenceerror $ is not defined in yii2?
Answer: 2 Answers. Yii2 injects scripts (jquery and the like) last on your page. ... But it means that the jQuery will load AFTER your script, so when your script runs, jQuery does not yet exist. The easiest way for quick testing is to move yii-scripts (jquery and the like) to the head of the page.