You’re all stoked to get going on a new project. Everything seems to be coming together faster than ever, but your little console.log('hi jake!') smoke signal isn’t burning. Instead, you’re getting an obnoxious $ is not defined. You’re 100% sure you included jQuery before your script, and I’m 100% sure you need to wrap your code in an IIFE. Not just any old IIFE– one that hands a $ reference to jQuery.


####Just do this, and have a great day!

(function($){
  // Oh man, so many codes! 
}(jQuery));

Hopefuly you want to understand what’s happening behind the scenes– Greg Franko does a great job explaining why he loves his iife, and gives some great examples of how we can use them to make our lives better.


← Back