WordPress: My JS files are not executing any of their code, nor do they return a 404 error

Here’s my jQuery code:

jQuery(document).ready(function() {
    var $window = jQuery(window);

    console.log("Pre-page height: " + $window.height());
    jQuery('.main-content .home-block').height($window.height());

    $window.on('resize', function(){
        console.log("Resize event height: " + $window.height());
        jQuery('.main-content .home-block').height($window.height());
    });
});

This is my current <head> code:

Read More
  <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php cs_wp_title(); ?></title>
    <?php if( ! cs_get_option( 'non_responsive' ) ) { ?>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <?php } else { ?>
    <meta name="viewport" content="width=1200">
    <?php } ?>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js" />
    <!-- Start of imported scripts -->
    <script type="text/javascript" src="/js/customjs/main.js" />
    <script type="text/javascript" src="/js/panelsnap/jquery.panelsnap.js" />
    <!-- End of imported scripts -->
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <?php if ( is_search() || is_404() ) { echo '<meta name="robots" content="noindex, nofollow" />'; } ?>
    <?php if ( cs_get_option( 'favicon' ) ) { echo '<link rel="shortcut icon" href="'. cs_get_option( 'favicon' ) .'" />'; } ?>
    <?php wp_head(); ?>
  </head>

My console is clean, and there is no error visible. Nothing strange is happening on my page as well. What’s the problem here?

Related posts

1 comment

  1. Alright, here’s a lesson well learned:

    Always check your jQuery CDN.

    It wasn’t working. A normal console.log or alert gave me a response, but anything with a jQuery selector would derp out.

    I switched from the jQuery CDN:

    <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js" />
    

    To the Google CDN

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    

    And it started working.

Comments are closed.