Optimizing theme for Pagespeed

Homepage Community Forums SquareOne Theme Support Optimizing theme for Pagespeed

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #20454
    Andrés
    Customer

      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!

      #20480
      Wes
      Moderator

        Do you know if you’re supposed to add this to your functions.php file? That’s where most custom code goes if you need to make global changes to your site. The first block of code you posted is already there in the functions.

        Is there an article/tutorial that you’re referencing for this?

        Also, if you’re not familiar with PHP code, then I would HIGHLY recommend using FTP to edit your theme files when you do add your code. It will allow you to make edits and undo any mistakes. The WP admin editor won’t let you do this if a mistake does happen.

        #20507
        Andrés
        Customer
          #20551
          Wes
          Moderator

            If you just need to enqueue a script or two, do a search for “How to Enqueue Scripts in Genesis” and you’ll see some tutorials pop up that should help. Here’s one for example – http://crunchify.com/genesis-framework-how-to-enqueue-scripts-and-css-into-child-theme/ There’s more out there that you can Google if you need more details.

            If you’re hosting a javascript file from your own site, then you can link to it as suggested in the post, and/or it also shows how to link to external scripts as well.

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.