Category: WordPress Optimization

  • [Contact Form 7] How to set Recaptcha.js so that it does not load on anything other than the contact page.

    [Contact Form 7] How to set Recaptcha.js so that it does not load on anything other than the contact page.

    I am creating a contact form using Contact Form 7. I use Recaptcha to prevent spam, but because of this, Recaptcha.js always comes up in Pagespeed Insights in “Eliminate render-blocking resources” or in “Reduce unused JavaScript”. Therefore, I researched and implemented a method to prevent Recaptcha.js from loading on pages other than the contact page. Try putting the following code in functions.php.

    function block_recaptcha_badge() {
     if ( !is_page( array( 'contact-me' ) ) ) {
     wp_dequeue_script( 'google-recaptcha' );
     wp_deregister_script( 'google-recaptcha' );
     add_filter( 'wpcf7_load_js', '__return_false' );
     add_filter( 'wpcf7_load_css', '__return_false' );
     }
    }
    add_action( 'wp_print_scripts', 'block_recaptcha_badge' );

    If you have multiple contact form pages, you can increase the array(‘contact-me’ part, like below.

    array( ‘contact-me’, ‘contact-me’, ‘contact-me-3’

  • How to load WordPress JavaScript asynchronously

    How to load WordPress JavaScript asynchronously

    By putting the following code in functions.php, you can load WordPress JS asynchronously. Effective if jquery.js or jquery-migrate.min.js appears in “Exclude resources that prevent rendering” in PageSpeed ​​Insights.

    if ( !(is_admin() ) ) {
        function replace_scripttag ( $tag ) {
            if ( !preg_match( '/\b(defer|async)\b/', $tag ) ) {
                return str_replace( "type='text/javascript'", 'async', $tag );
            }
            return $tag;
        }
        add_filter( 'script_loader_tag', 'replace_scripttag' );
    }

    However, if I do this, my PageSpeed ​​Insights score will go up, but the Cocoon blog card image won’t display properly, so I changed it back.

  • [WordPress] Speed up your website

    [WordPress] Speed up your website

    Speeding up your WordPress website is crucial for improving user experience, search engine rankings, and conversion rates. Here’s a detailed guide on how to effectively enhance your website’s performance:

    (more…)
  • Should I use web fonts with WordPress?

    Should I use web fonts with WordPress?

    I don’t recommend this because it slows down the display. If you really want to use it, you should upload the fonts and host it.

  • What should I do if WordPress is slow?

    What should I do if WordPress is slow?

    If your WordPress site is running slow, there are several strategies you can implement to improve its performance. Reducing the number of plugins is indeed a good starting point, but there are other effective measures you can take:

    (more…)
  • How can I increase page views on my site?

    How can I increase page views on my site?

    Increasing page views on your site is a multifaceted task that involves optimizing content, design, and user experience. Here are some strategies to help you achieve this goal:

    (more…)