Some themes are using outdated jquery files

Hi. I noticed that some themes are also loading their own jquery file, which is outdated and sometimes conficts with plugins.

The themes are:

-Oceanwide theme: uses local jquery file. jQuery 1.1.4

-jQ theme: uses local juery v1.3.2

-mandigo jQuery 1.2.6

-oceanmist jQuery 1.1.4

My question are

1. Is it safe to remove the reference to those files (since the blog also load the default jquery.js from /wp-includes)

2. If yes, in header.php should I move the other *.js below wp_head()? Do I have to keep the <script lan…> call to the other scripts as it is now or is it OK to add them to the wp_enqueue_script instead?

3. Is it also safe to update the other *.js files which are used in those themes

e.x. cycle.js in oceanmist with http://malsup.github.io/jquery.cycle.all.js?

Thanks in advance

Lena

  • aristath
    • Recruit

    Hello again @stergatu!

    1. Is it safe to remove the reference to those files (since the blog also load the default jquery.js from /wp-includes)

    Yes, it’s safe.

    2. If yes, in header.php should I move the other *.js below wp_head()? Do I have to keep the <script lan…> call to the other scripts as it is now or is it OK to add them to the wp_enqueue_script instead?

    Well, it depends… If I remember correctly some scripts like modernizr must be loaded before jquery. Other scripts that are jQuery-dependent should be moved after it.

    And yes, it’s ok to add them using wp_enqueue_script();

    3. Is it also safe to update the other *.js files which are used in those themes

    I would say yes… and in some cases even necessary for them to play nicely with the latest jQuery that you’ll be using.

    I hope that helps!

    Cheers,

    Ari.

  • stergatu
    • Site Builder, Child of Zeus

    Thanks Aristath for your prompt answer.

    It is good that we are in the same timezone :slight_smile:

    I ‘ll share the changes I make so the theme developer can add them – if he wants – into the next update of Farms 133 theme pack

    Bests Lena

  • stergatu
    • Site Builder, Child of Zeus

    Fix for Mandigo theme.

    1. On header.php.

    Comment or delete the 2 lines

    <script type="text/javascript" src="<?php echo $dirs['www']['js'];?>jquery.js"></script>
    <script type="text/javascript" src="<?php echo $dirs['www']['js'];?>jquery.ifixpng.js"></script>

    2. on functions.php add the following after the load_theme_textdomain… line

    function add_mandigo_js_script() {
    wp_enqueue_script('ifixpng', get_template_directory_uri() . '/js/jquery.ifixpng.js', array('jquery'));
    }
    add_action('wp_enqueue_scripts', 'add_mandigo_js_script');

    3. delete (if you want) from folder js the file jquery.js

  • stergatu
    • Site Builder, Child of Zeus

    Fix for Oceanwide theme.

    1. On header.php.

    Delete the 2 lines 53-54

    <script src="<?php bloginfo('stylesheet_directory');?>/js/jquery.js" type="text/javascript"></script>
    <script src="<?php bloginfo('stylesheet_directory'); ?>/js/cycle.js" type="text/javascript"></script>

    2. On functions.php

    Add on line 14 the following:

    function add_oceanwide_js_script() {
    wp_enqueue_script('cycle', get_template_directory_uri() . '/js/cycle.js', array('jquery'));
    }
    add_action('wp_enqueue_scripts', 'add_oceanwide_js_script');

    3. delete (if you want) from folder js the file jquery.js

  • stergatu
    • Site Builder, Child of Zeus

    Fix for Oceanmist theme.

    1. On header.php

    Move line 66

    <?php wp_head(); ?> at line 48.

    Delete the lines 46-47

    <script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.js" type="text/javascript"></script>
    <script src="<?php bloginfo('stylesheet_directory'); ?>/js/cycle.js" type="text/javascript"></script>

    2. On functions.php add at line 14 the following:

    function add_oceanmist_js_script() {
    wp_enqueue_script('cycle', get_template_directory_uri() . '/js/cycle.js', array('jquery'));
    }
    add_action('wp_enqueue_scripts', 'add_oceanmist_js_script');

    3. delete (if you want) from folder js the file jquery.js

  • stergatu
    • Site Builder, Child of Zeus

    Fix for jQ theme.

    This is a little more tricky.

    1. Visit https://github.com/joeldbirch/superfish/ and download

    from https://github.com/joeldbirch/superfish/tree/master/src/js the files:

    – superfish.js

    -supersubs.js

    from https://github.com/joeldbirch/superfish/tree/master/src/css download the file

    -superfish.css

    2. Replace your themes lib/js/ files with the new ones superfish.js

    supersubs.js and the file lib/css/superfish.css

    3. Open files /lib/js/theme.js and /lib/js/fontResizer.js and replace

    $(document).ready(function()

    with

    jQuery(document).ready(function ($)

    4. On header.php delete the lines 30-35

    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/jquery.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/superfish.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/supersubs.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/cookies.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/fontResizer.js"></script>
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lib/js/theme.js"></script>

    5. On functions.php add on line 17 the following

    function add_jq_js_script() {

    wp_enqueue_script('superfish', get_template_directory_uri() . '/lib/js/superfish.js', array('jquery'));
    wp_enqueue_script('supersubs', get_template_directory_uri() . '/lib/js/supersubs.js', array('jquery'));
    wp_enqueue_script('cookies', get_template_directory_uri() . '/lib/js/cookies.js', array('jquery'));
    wp_enqueue_script('fontResizer', get_template_directory_uri() . '/lib/js/fontResizer.js', array('jquery'));
    wp_enqueue_script('theme', get_template_directory_uri() . '/lib/js/theme.js', array('jquery'));
    }
    add_action('wp_enqueue_scripts', 'add_jq_js_script');

    6. Delete (if you want) from folder /lib/js the file jquery.js

    Bests Lena

  • stergatu
    • Site Builder, Child of Zeus

    Fix for colorpaper theme.

    Just 2 steps.

    1. On header.php remove line 62

    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery-1.2.6.min.js"></script>

    2. Delete (if you want) from folder /js the file jquery-1.2.6.min.js