| adding js scripts via wp enque results in no scripts working
|
surrealillusions

msg:4477321 | 10:22 pm on Jul 19, 2012 (gmt 0) | 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

msg:4477333 | 11:03 pm on Jul 19, 2012 (gmt 0) | 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

msg:4477504 | 1:52 pm on Jul 20, 2012 (gmt 0) | 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

msg:4477534 | 2:49 pm on Jul 20, 2012 (gmt 0) | 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

msg:4478054 | 8:39 pm on Jul 22, 2012 (gmt 0) | 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

msg:4478740 | 11:49 am on Jul 25, 2012 (gmt 0) | 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

msg:4478758 | 1:08 pm on Jul 25, 2012 (gmt 0) | Ah. Glad you got it sorted!
|
|
|