• Resolved bward

    (@bward)


    Good morning!

    The printfriendly.js file loads by default on all pages which increases page load time. How can I dequeue this script so it’s only loaded on the pages it needs to loaded on? We have done this with all of our scripts and really sped up our site. Thank you!

    Example:

    function printfriendly_dequeue_script() {
        // if this is not a singluar page remove the script
    	if (  ! is_singular () ) {
    		wp_dequeue_script( 'printfriendly' );
    	}
    }
    add_action( 'wp_print_scripts', 'printfriendly_dequeue_script' );
    • This topic was modified 4 years, 3 months ago by bward.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    What version of the plugin are you using?

    Thread Starter bward

    (@bward)

    Thanks so much for the reply. We are using it on the latest and greatest code of Version 3.14.7.

    Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    Can you share the URL to a page we can observe the issue?

    Thread Starter bward

    (@bward)

    Yes, do you have a contact form so I can send the link instead of making it public?

    Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    Yes we sure do. I’m going to resolve here as we move to our internal email.

    EDIT: I forgot the link!

    Email at https://support.printfriendly.com/contact

    Thread Starter bward

    (@bward)

    Patiently waiting for someone to assist with this matter. I did use the contact form.

    Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    Hmm, I haven’t been able to find the email. Can you please email directly at pro@printfriendly.com?

    Thread Starter bward

    (@bward)

    It happens no worries. I did just email you. Thanks so much.

    Thread Starter bward

    (@bward)

    If you did not receive my last email, can you just explain how to dequeue your scripts please.

    function printfriendly_dequeue_script() {
        // if this is not a singluar page remove the script
    	if (  ! is_singular () ) {
    		wp_dequeue_script( 'YOUR-SCRIPT-ACTION' );
    	}
    }
    add_action( 'wp_print_scripts', 'printfriendly_dequeue_script' );

    Notice in the example above, I just need to understand how you call your script. Then I can disable it on the pages I do not need it to run on. I need to place your scripts call action where I have “YOUR-SCRIPT-ACTION”.

    I do this for all of our plugins that load scripts on all pages. Most people do not need that and it keeps the site running very quick and clean.

    Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    Inside the plugin folder is a file called pf.php. You can see how we’re calling the script from there starting at line 424.

    In the plugin, the function is print_script_footer()

    Thread Starter bward

    (@bward)

    I appreciate you getting back to me here. Could there be another call?

    Even a basic function as below, which should remove it from all pages does not work.

    function pf_dequeue_script() {
        wp_dequeue_script( 'print_script_footer' );
    }
    add_action( 'wp_print_scripts', 'pf_dequeue_script', 100 );
    Plugin Author Print & PDF by PrintFriendly

    (@printfriendly)

    Please take a look at plugins/printfriendly/pf.php to see how we’re calling the script.

    Unfortunately we’re not familiar with this issue, nor able to replicate on our test sites.

    Thread Starter bward

    (@bward)

    That’s okay. I do appreciate you trying to help.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How To Dequeue Printfriendly.js?’ is closed to new replies.