I am having problems enqueuing javascript. When I use the script tag in the head section of my site, everything works just fine. If I take the scripts out and use enqueue, the site breaks but I don't get any errors in firebug. Viewing the source code, the entire page looks as if it is there but obviously some of the js scripts are not working and this causes my site to crash. Is there a way to find out why it's crashing? The console has nothing in it.
I would link to the site but I am going to continue working and since things will change, the link won't be much good. I am looking for tips to debugging js errors. Where can I look?
my method of enqueueing the script
wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js',array('jquery'),'',true);
wp_enqueue_script('isotope');
function bliss_jsscripts(){
if( !is_admin()){
wp_register_script('supersized', get_template_directory_uri() . '/js/supersized.3.2.6.js',array('jquery'), false, true);
wp_enqueue_script('supersized','','',false,'');
}
}
add_action('wp_enqueue_scripts', 'bliss_jsscripts', 999);
WP_DEBUG
, and do you receive any PHP/WordPress error messages? Have you tried registering the script to print in the header instead of the footer (by setting the last argument ofwp_register_script()
tofalse
instead oftrue
)? I'd also recommend setting the$version
argument tofalse
rather than an empty string''
while debugging this issue. Are you properly callingwp_enqueue_script()
within a hook attached to thewp_enqueue_scripts
action? In what file is this?wp_register_script()
you're passing arguments to print your script in the footer - not the header - for starters. Additionally, when you callwp_enqueue_script()
with all those empty strings, you're over-writing many of the arguments that you set inwp_register_script()
... I recommend spending some time reviewing the Codex entries for these two functions before we troubleshoot this further.wp_register_script()
entirely and usewp_enqueue_script()
alone - it will register the script itself if it sees it's not already registered. Additionally, you shouldn't have any calls towp_enqueue_script()
outside of a function hooked to the'wp_enqueue_scripts'
action - the Codex mentions all of this, don't be afraid to dig ;) . It would also still be helpful if you could share the properly functioning script tag that you are attempting to reproduce with WordPress functions.