• Hi!

    Thanks a lot for the amazing plugin. ??

    Is there any chance you could patch things up to enqueue the gdpr-public.js script in the footer instead of the header? It would be a little more performance friendly, in the run for optimization.

    For those who might be interested, I’m currently doing it that way :

    
    /**
     * Move GDPR JS to footer
     */
    function move_gdpr_to_footer() {
        wp_dequeue_script('gdpr' );
        wp_deregister_script( 'gdpr' );
        wp_enqueue_script( 'gdpr', get_stylesheet_directory_uri() . '/libs/gdpr-public.js', array(), null, true );
        wp_localize_script(
            'gdpr', 'GDPR', array(
                'ajaxurl'           => admin_url( 'admin-ajax.php' ),
                'logouturl'         => is_user_logged_in() ? esc_url( wp_logout_url( home_url() ) ) : '',
                'i18n'              => array(
                    'aborting'              => esc_html__( 'Aborting', 'gdpr' ),
                    'logging_out'           => esc_html__( 'You are being logged out.', 'gdpr' ),
                    'continue'              => esc_html__( 'Continue', 'gdpr' ),
                    'cancel'                => esc_html__( 'Cancel', 'gdpr' ),
                    'ok'                    => esc_html__( 'OK', 'gdpr' ),
                    'close_account'         => esc_html__( 'Close your account?', 'gdpr' ),
                    'close_account_warning' => esc_html__( 'Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?', 'gdpr' ),
                    'are_you_sure'          => esc_html__( 'Are you sure?', 'gdpr' ),
                    'policy_disagree'       => esc_html__( 'By disagreeing you will no longer have access to our site and will be logged out.', 'gdpr' ),
                ),
                'is_user_logged_in' => is_user_logged_in(),
                'refresh'           => get_option( 'gdpr_refresh_after_preferences_update', true ),
            )
        );
    }
    add_action( 'wp_enqueue_scripts', 'move_gdpr_to_footer' );
    

    That change would be minim and would only require to change the last parameter from false to true in /public/class-gdpr-public.php on line 124.

    Cheers!
    Charlie

  • The topic ‘Enqueue scripts in footer for performance’ is closed to new replies.