| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|adding js scripts via wp enque results in no scripts working|
Putting the scripts in the header with <script> tags, and everything is fine, works ok. Now, I know this not to be a good way to add scripts.
I've looked into the wp_enque stuff. I changed the default WP jQuery to the Google hosted file, and another jQuery related script, via a plugin, works fine.
But, since I added the other 2 scripts via wp_enque, they have stopped working.
Now, the 2 scripts both have a JS file (which is on the server) and both have an extra bit of JS, which, under normal circumstances is added
// do some stuff
like that in the header.
I've added that into an extra file for each script.
All scripts are called in, no 404's been made. jQuery is called in. All the scripts in the header and after jQuery.
But no luck.
Any ideas on why they would stop working via the wp_enque way?
The issue is likely the load order of the scripts. If the jQuery is loaded after the scripts try to execute they won't work.
The order of the scripts are ok.
JS File 1
JS file 2 (with the extra bit of JS to launch the JS effect for JS file 1)
JS File 3
JS file 4 (with the extra bit of JS to launch the JS effect for JS file 3)
Do you have a duplicate call to jQuery in there? Some plugins add the code and you may be loading it twice.
Bottom line is I doubt it's enque and I strongly suspect it has to do with calls to jQuery.
Here are the JS files. These are the first JS files to be called in (apart from a moderniser JS to help IE and older browsers display HTML5).
As displayed in source code of the site.
If I take them out of the enque method, and place them manually into the header, then they work.
Turns out to be a jQuery.noconflict line in the wp-super-popup plugin. Remove that, and all is working fine. All scripts in the wp_enque function.
Ah. Glad you got it sorted!
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved