WPDIR
Everything and everyone WordPress

How to use “$” instead of typing “jQuery” so many times in WordPress

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #495 Reply
    Dennis
    Guest
    #496 Reply
    Kevin
    Guest

    “If the script is being loaded in the footer (which you should be doing in the vast majority of cases) you can wrap the code in an anonymous function (technically any IIFE) where you pass in jQuery to be mapped to $.”

    (function($) {
    	
    	// $ Works! You can test it with next line if you like
    	// console.log($);
    	
    })( jQuery );
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How to use “$” instead of typing “jQuery” so many times in WordPress