Avoiding the framework $ conflict
$
is very commonly used in many JavaScript frameworks as a function name or variable name. When two different JavaScript libraries are used together, there is high chance of conflict in use of the $ symbol, as they might use it for different purposes. Let's suppose two frameworks are used in a page and these are jQuery and prototype.js
:
<script type="text/javascript" src="prototype.js"></script> <script type="text/javascript" src="jquery.js"></script>
When two frameworks are used together and both frameworks use the $
symbol, the result can be unpredictable and may break as jQuery considers $
as a jQuery object, while in prototype.js
, it's a DOM accessing function. The code $('mydiv').hide();
might not work properly in the web page containing the preceding JavaScript framework's usages. This is because, jQuery is included in the last line but the code $('mydiv').hide();
is code from the prototype.js
framework, which leads to an unexpected...