Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to optimise my site for mobile and enqueued my scripts to be placed in the footer so as to eliminate render-blocking javascript in above the fold content. Unfortunately some of the plugins the site uses do not do so. Is there a way to have some control over where their scripts are placed without hacking the plugin?

Here is how the scripts I added are enqueued:

function test() {

wp_enqueue_script( 'hostel_mama-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    wp_enqueue_script( 'comment-reply');
}

if ( is_singular() && wp_attachment_is_image() ) {
    wp_enqueue_script( 'hostel_mama-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202', true );
}
}
add_action( 'wp_enqueue_scripts', 'test' );

 if ( ! function_exists( 'frontend_assets' ) ) :

 function frontend_assets() {

if (!is_admin()) {
    wp_enqueue_style( 'hostel_mama-style', get_stylesheet_uri() );

    wp_enqueue_script( 'foundation', get_template_directory_uri() . '/js/foundation.min.js', null, '4.0', true );
    wp_enqueue_script( 'modernizr', get_template_directory_uri().'/js/vendor/custom.modernizr.js', null, '2.1.0');

    wp_enqueue_script( 'hostel_mama-custom', get_template_directory_uri() . '/js/scripts.js', array('jquery','jquery-ui-datepicker'), '1.0', true );

    wp_enqueue_script('google-maps', '//maps.google.com/maps/api/js?key=AIzaSyCSAVx-HQFqCCFvzQ_WIJCDLZL2uiOIvSA&sensor=true', array(), '3', true);

    wp_enqueue_style( 'google-fonts', 'http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,300italic,400italic|Bitter|Squada+One' ); 
 }
}
add_action( 'wp_enqueue_scripts', 'frontend_assets' );

endif;

Here is a link to the site : http://plug-inn.kirstencassidy.com/

Here is the plugin code that adds the scripts:

// register acf scripts
    $scripts = array();
    $scripts[] = array(
        'handle' => 'acf-field-group',
        'src' => $this->settings['dir'] . 'js/field-group.min.js',
        'deps' => array('jquery')
    );
    $scripts[] = array(
        'handle' => 'acf-input',
        'src' => $this->settings['dir'] . 'js/input.min.js',
        'deps' => array('jquery')
    );
    $scripts[] = array(
        'handle' => 'acf-datepicker',
        'src' => $this->settings['dir'] . 'core/fields/date_picker/jquery.ui.datepicker.js',
        'deps' => array('jquery', 'acf-input')
    );


    foreach( $scripts as $script )
    {
        wp_register_script( $script['handle'], $script['src'], $script['deps'], $this->settings['version'] );
    }

This in turn is called by:

function field_group_admin_enqueue_scripts()
{
    wp_register_script( 'acf-field-group-repeater', $this->settings['dir'] . 'js/field-group.js', array('acf-field-group'), $this->settings['version']);

    // scripts
    wp_enqueue_script(array(
        'acf-field-group-repeater', 
    ));
}

The only add_action that applies is :

add_action('init', array($this, 'init'), 1);
share|improve this question
    
Please include relevant Plugin code used to enqueue scripts. –  Chip Bennett Nov 7 '13 at 13:08
    
There you go. The only ones that I think need to be in the head are modernizer and google webfonts. (I think) –  mantis Nov 7 '13 at 13:16
    
Wait a second. Why didn't you undelete your old question? –  kaiser Nov 7 '13 at 13:17
    
I thought it was badly explained and was trying to explain it better. –  mantis Nov 7 '13 at 13:18
    
And again: Where's the link to your site? ... sigh And btw, when you undelete a question, you can again edit it. –  kaiser Nov 7 '13 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.