Magento – “ReferenceError: $j is not defined”

jquerymagento-1.9

I see this error in the firebug.

"ReferenceError: $j is not defined"

I read that it is to do with jquery file.
I have following code in my theme in local.xml file.

    <default>
        <reference name="head">
            <!-- Link to external JavaScript file (e.g Jquery CDN)-->
            <block type="core/text" name="google.cdn.jquery">
                <action method="setText">
                     <text><![CDATA[<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script>window.jQuery||document.write('<script src="/skin/frontend/default/mytheme/js/jquery.min.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
                </action>
            </block>
            </reference>
            </default>

What is this error? How can I solve?

Best Answer

I think that your library is loaded after the function $j this is why it is not recognized, to solve this, try to remove the library, add your file.js then add the library like this:

local.xml

<reference name="head">
     //...
     <action method="removeItem"><type>skin_js</type><name>js/path_to_your_lib</name></action>
     <action method="addItem"><type>skin_js</type><name>js/path_to_your_lib</name></action>            
     <action method="addItem"><type>skin_js</type><name>js/yourfile.js</name></action> //where you call $j

     </reference>