Hi! I’m trying to optimize my web (www.misterlogo.es) to get the best results on Pagespeed. My PHP skills are 0, so I need a little help for that.
One thing I have to do y to load the Javascript in the footer. And there are some lines I have to change:
//* Enqueue Scripts/Styles
add_action( 'wp_enqueue_scripts', 'squareone_enqueue_scripts_styles' );
function squareone_enqueue_scripts_styles() {
wp_enqueue_script( 'squareone-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_style( 'dashicons' );
wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,500,600', array(), PARENT_THEME_VERSION );
wp_enqueue_style( 'prefix-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', array(), '4.0.3' );
}
I’ve read to set the last parameter to “TRUE”. Here are some examples:
wp_enqueue_script(‘site-search’, get_stylesheet_directory_uri() . ‘/js/site-search.js’, [‘jquery’], NULL, true);
// Defer jQuery to Footer
add_action( ‘wp_enqueue_scripts’, ‘defer_jquery’ );
function defer_jquery() {
if ( !current_user_can( ‘edit_pages’ ) ) {
wp_deregister_script( ‘jquery’ );
wp_register_script( ‘jquery’, includes_url( ‘/js/jquery/jquery.js’ ), false, NULL, true );
wp_enqueue_script( ‘jquery’ );
}
}
But I don’t know how to apply that to the theme code. Any suggestion?
Thanks!