• Resolved Nico

    (@nico23)


    There is no need to load all the heavy scripts on every WordPress page. You can call wp_enqueue_script at any time b4 the footer scripts are printed. I guess there is no need to load the scripts in the <head>.

    To do this, remove this line from the WPSC_Frontend class:

    add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_scripts' ) );

    And then you load the scripts only when the shortcodes are actually used on pages. You can call WPSC_Frontend::load_scripts() inside all the layout methods for all the shortcodes where the scripts are needed.

    	final class WPSC_Shortcode_One {
    
    		// ...
    
    		/**
    		 * "supportcandy" shortcode layout
    		 *
    		 * @param array $attrs - Shortcode attributes.
    		 * @return string
    		 */
    		public static function layout( $attrs ) {
    			\WPSC_Frontend::load_scripts();

    I would appreciate if you do this and test it, it seems to work fine for me. That way, people sites are not polluted with all these scripts that are only needed for the support page(s). Especially because these are quite a lot and they are typically backend scripts.

    Great plugin btw, thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Milind Ighe

    (@miliighe)

    Hello @nico23,

    Thanks for contacting us. Hope you are doing well.

    Thank you for valuable suggestion. I will forward it to our development team.

    Meanwhile, we have address this issue by another way, you can select the pages on which you want to load SupportCandy Script.

    Please go to Dashboard > Support > Settings > Miscellenious > Advanced > Load Script > Custom > Select the Pages > Submit.

    I hope this will resolve the issue, please feel free to get back to us if you face any other issues.

    Thank you.

    Thread Starter Nico

    (@nico23)

    I do not understand what you are doing and saying. I do not have these options you speak off. Do you mean they will be implemented in the next version?

    And why would you do it that way? I showed you how to do it without any options automatically. Having it as an option that you manually have to select the pages where the script loads makes no sense if you can just have the shortcodes automatically load them.

    eros86

    (@eros86)

    @nico23 and @miliighe I can see this option in other place Dashboard > Support > Settings > General Settings > Page settings and at bottom of page > Load scripts

    Changing this option increase speed of my page for mobile from 59 to 82 at mobile device

    Plugin Support Milind Ighe

    (@miliighe)

    Hello @nico23,

    The above reply from @eros86 is correct. There was a typing mistake on my end. You can find the settings to control the loading of script on selected pages from Dashboard > Support > Settings >?General Settings > Page settings > Load scripts.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Please optimize the plugins script loading’ is closed to new replies.