I’m trying to put together a WordPress site with a JQuery slider plugin, but the plugin doesn’t display on the page and I always get the above error message.
Despite trying several different fixes suggested in other’s posts I still can’t seem to fix the above error, including putting the script tag in the ‘header.php’ file. Any help would be much appreciated – thanks!
Relevant code in ‘footer.php’ file
<!--Load JQuery-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</body>
</html>
The Website:http://www.advanceprojects.com.au/
Scripts always run in a sequential order.
So basically you are trying to use jQuery even before the jQuery library is loaded.
Your script is dependent on Nivo which in turn depends on jQuery library.
Either move the script to the line after the library is loaded, or move the library declaration to the head.
Also make sure you enclose the script inside
DOM Ready
handler.So the order in which you should be loading these are
This worked for me.
Add the line
This error happened because jquery is not included, and should be included before loading any other script.
Here is an example:
firstplugin.php
test.js
See The Link How to add css and Js File
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
Probably Before JQuery,Your Js File Is Loaded.
So add js file after Jquery file is Loaded
Example
In a recent version of WordPress this can be caused by core performance improvements:
Try placing this in your wp.config file:
I am seeing this same issue with WooCommerce and the Siteground Optimizer when Defer Render Blocking Javascript is on, there is a WC script that references jQuery first (seems to be a date picker script setting defaults) – not a custom script I’ve added, and not a plugin as far as I can tell. My scripts use jQuery and come later, and are fine, but this references it in the head tag prior to jQuery being available… Also this only happens while NOT logged in. If you’re logged in, it works fine, log out, broken.
Turning off the Defer Javascript option in SG Optimizer seems to fix the issue.
Use
instead of
$(window).load(function() {... })
is explicitly binding to the window’s load event, your code has already fired beforejQuery
library is loaded. You have to useDOM Ready
handler.