0

I'd really appreciate any light you folks could shed on this issue. I was tipped off by Firebug that the function 'videojs' is not defined, when it tried to run the block of script which links to the swf object:

<script>videojs.options.flash.swf = "<?php echo get_template_directory_uri(); ?>/loose/video-js.swf"</script>

So I opened firebug and went to the scripts pane, and sure enough, video.js is not being enqueued.

For reference, here are all of my enqueues:

add_action('wp_enqueue_scripts', 'lw_scripts_5', 5);
add_action('wp_enqueue_scripts', 'lw_scripts_10', 10);
function lw_scripts_5() {
wp_enqueue_script('modernizr', get_template_directory_uri().'/js/modernizr.custom.90599.js', array(''), null, false);
}
function lw_scripts_10() {
//jQuery UI
wp_enqueue_script('jquery-ui', get_template_directory_uri().'/js/jquery-ui.min.js', array('jquery'), null, true);
wp_enqueue_style('jquery-ui', get_template_directory_uri().'/css/jquery-ui.css');
//Twitter Bootstrap - http://getbootstrap.com
wp_enqueue_script('bootstrap', get_template_directory_uri().'/js/bootstrap.min.js', array('jquery'), null, true);
wp_enqueue_style('bootstrap', get_template_directory_uri().'/css/bootstrap.min.css');
//bxSlider
wp_enqueue_script('bxslider', get_template_directory_uri().'/js/jquery.bxslider-rahisified.min.js', array('fitvids', 'easing'), null, true);
wp_enqueue_style('bxslider', get_template_directory_uri().'/css/jquery.bxslider.css');
//Video.js
wp_enqueue_script('video-js', get_template_directory_uri().'/js/video.js', array('modernizr'), null, true);
wp_enqueue_style('video-js', get_template_directory_uri().'/css/video-js.min.css');
//Loose JavaScript
wp_enqueue_script('fitvids', get_template_directory_uri().'/js/jquery.fitvids.js', array('jquery'), null, true);
wp_enqueue_script('easing', get_template_directory_uri().'/js/jquery.easing.1.3.js', array('jquery'), null, true);
wp_enqueue_script('laughlinweb-main', get_template_directory_uri().'/js/laughlinweb.js', array('jquery', 'jquery-ui', 'bootstrap', 'bxslider', 'video-js'), null, true);
//Loose CSS
wp_enqueue_style('normalize', get_template_directory_uri().'/css/normalize.css');
}

Everything but video.js loads successfully. I don't really consider using a plugin to be a viable solution, I'd actually like to learn this (considering I call myself a web developer, I can't really compromise by using someone else's code. Just their advice ;-)

Normally I would just take a shower but this really doesn't feel like the kind of problem I'm going to solve alone. Can anyone spot the reason video.js is not being included?

I have the HTML5 Video shiv included in my custom modernizr (actually, I have everything included in it like a n00b) so I don't believe deferring to the footer is causing the issue. I've tried changing it to false to enqueue into the <head>, and no difference. Either way, I'm sure the script would at least show up in Firebug, even if I got that part wrong.

So does anyone see why this script is not making it into the page? I'm running on localhost and no caching plugins are installed.

My greatest thanks to anyone who can help me brain this. <3

  • I don't see any problem with your code. Are you dequeing the script from somewhere? – sakibmoon May 30 '15 at 21:01
1

It could be a couple of things:

  1. video.js doesn't exist at get_template_directory_uri().'/js/video.js'
  2. WP isn't recognizing modernizr as a registered script, so it won't enqueue video-js

A couple of things to try/research:

  1. Is there any plugin already registering a script named modernizr and/or video-js?
  2. Try registering (not enqueueing) modernizr within your lw_scripts_10 like so:

    function lw_scripts_10() {
    
       wp_register_script('modernizr', get_template_directory_uri().'/js/modernizr.custom.90599.js', array(''), null, false);
    
        //jQuery UI
        wp_enqueue_script('jquery-ui', get_template_directory_uri().'/js/jquery-ui.min.js', array('jquery'), null, true);
        wp_enqueue_style('jquery-ui', get_template_directory_uri().'/css/jquery-ui.css');
    
        //Twitter Bootstrap - http://getbootstrap.com
        wp_enqueue_script('bootstrap', get_template_directory_uri().'/js/bootstrap.min.js', array('jquery'), null, true);
        wp_enqueue_style('bootstrap', get_template_directory_uri().'/css/bootstrap.min.css');
    
        //bxSlider
        wp_enqueue_script('bxslider', get_template_directory_uri().'/js/jquery.bxslider-rahisified.min.js', array('fitvids', 'easing'), null, true);
        wp_enqueue_style('bxslider', get_template_directory_uri().'/css/jquery.bxslider.css');
    
        //Video.js
        wp_enqueue_script('video-js', get_template_directory_uri().'/js/video.js', array('modernizr'), null, true);
        wp_enqueue_style('video-js', get_template_directory_uri().'/css/video-js.min.css');
    
        //Loose JavaScript
        wp_enqueue_script('fitvids', get_template_directory_uri().'/js/jquery.fitvids.js', array('jquery'), null, true);
        wp_enqueue_script('easing', get_template_directory_uri().'/js/jquery.easing.1.3.js', array('jquery'), null, true);
        wp_enqueue_script('laughlinweb-main', get_template_directory_uri().'/js/laughlinweb.js', array('jquery', 'jquery-ui', 'bootstrap', 'bxslider', 'video-js'), null, true);
    
        //Loose CSS
        wp_enqueue_style('normalize', get_template_directory_uri().'/css/normalize.css');
    }
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.