Home Forums Plugin Support WP User Frontend Pro Remove unnessary scripts

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  madegood 5 years, 11 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #4358

    madegood
    Participant
    Post count: 13

    Hi,

    Please could you tell me how to prevent wpufe from loading external scripts when not necessary. For example, it is loading the following files on every page, when I only want them to load on a page with a form on;

    /wp-content/plugins/wp-user-frontend-pro/css/jquery-ui-1.9.1.custom.css?ver=3.5.1
    /wp-content/plugins/wp-user-frontend-pro/js/jquery-ui-timepicker-addon.js?ver=3.5.1
    /wp-content/plugins/wp-user-frontend-pro/js/frontend-form.js?ver=3.5.1

    Thanks in advance

    Will

    #4359

    Tareq Hasan
    Keymaster
    Post count: 2831

    When it's loaded once, the browser will cache the scripts and will serve the scripts from cache for later requests. So will it make difference to exclude them?

    #4361

    madegood
    Participant
    Post count: 13

    Hmmm, well it does make a difference because a majority of my users won't be using the plugin. Those three scripts alone come to over 100kb, which is about 20% of the size of my homepage. It all adds up at, and ultimately is a significant load when speed is important.

    Cheers

    #4362

    Tareq Hasan
    Keymaster
    Post count: 2831

    check the wpuf.php enqueue_scripts function. wp_enqueue_script calls are adding the scripts in page. So if you load those scripts in specific pages, add this code
    [php]
    global $post;

    if ( $post && (is_page( 133 ) || is_page( 34 )) ) {

    }
    [/php]

    Now move the scripts into this if block and give the page ids to load them in specific pages.

    #4364

    madegood
    Participant
    Post count: 13

    Okay, the function on around line 161, right? And I'm assuming I'll have to redo this every time I upgrade?

    Thanks for taking the time to look into this.

    #4366

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, 161 and you'll have to do it everytime.

    #4368

    madegood
    Participant
    Post count: 13

    Nice one

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Remove unnessary scripts’ is closed to new replies.