Cancel jQuery ‘noConflict’ – is it really unsafe?

I use some external plugins (not wordpress plugins), that use ‘$’, and it’s very convenient for me to cancel noConflict mode, by adding this line
$=jQuery
But I guess they invented noConflict mode not for nothing.
The question is how much have to worry about it. And is really a problem to use $=jQuery?

Related posts

1 comment

  1. The problem with the $ alias is that a number of libraries quite puzzlingly decided to use the same variable as an alias. If two libraries try to use the same variable, one or the other will win and anything dependent on the other one will break.

    If you are only using jQuery, and never anything else, it should be fine to use the $ but you should not ever do that except for a site that you personally maintain. I suspect you will regret it if you ever want to use another library, though. Using that hack in a plugin or a theme would be very bad form.

    What you are doing is only marginally easier than this though (from the jQuery.noConflict docs):

    (function($) {
      $(function() {
        // more code using $ as alias to jQuery
      });
    })(jQuery);
    

    But then I don’t know what kind of “plugins but not WordPress Plugins” you are talking about, or whether that is even relevant.

    Reference

    http://api.jquery.com/jQuery.noConflict/

Comments are closed.