Welcome to WebmasterWorld Guest from 54.234.129.215

Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

adding js scripts via wp enque results in no scripts working

     

surrealillusions

10:22 pm on Jul 19, 2012 (gmt 0)

5+ Year Member



Hi,

For this site I'm developing, I've got a couple of Javascript scripts for a carousel and an image effect.

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

<script>
// do some stuff
</script>

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?

lorax

11:03 pm on Jul 19, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

surrealillusions

1:52 pm on Jul 20, 2012 (gmt 0)

5+ Year Member



The order of the scripts are ok.

jQuery
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)

lorax

2:49 pm on Jul 20, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

surrealillusions

8:39 pm on Jul 22, 2012 (gmt 0)

5+ Year Member



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.

<script type='text/javascript' src='http://example.com/wp-includes/js/comment-reply.js?ver=3.4.1'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js?ver=3.4.1'></script>
<script type='text/javascript' src='http://example.com/wp-content/themes/theme/_/js/jquery.carouFredSel.js?ver=1.0'></script>
<script type='text/javascript' src='http://example.com/wp-content/themes/theme/_/js/carouFredSelload.js?ver=1.0'></script>
<script type='text/javascript' src='http://example.com/wp-content/themes/theme/_/js/jQuery.BlackAndWhite.min.js?ver=1.0'></script>
<script type='text/javascript' src='http://example.com/wp-content/themes/theme/_/js/bwload.js?ver=1.0'></script>
<script type='text/javascript' src='http://example.com/wp-content/plugins/wp-super-popup/jquery.colorbox-min.js?ver=239102617'></script>
<script type='text/javascript' src='http://example.com/wp-content/plugins/wp-super-popup/jquery.utils-min.js?ver=613998020'></script>

surrealillusions

11:49 am on Jul 25, 2012 (gmt 0)

5+ Year Member



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.

lorax

1:08 pm on Jul 25, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Ah. Glad you got it sorted!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month