WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Stop WooCommerce Html Requests / Files on Site Load (12 posts)

  1. Waup
    Member
    Posted 11 months ago #

    Does anyone know how to stop woocommerce html requests and files loading on non-woocommerce URLs on a site? And only load when someone visits store pages.

    Currently the requests / files load on the homepage and all other pages, which adds numerous requests and payload to my site load.

    thanks

    http://wordpress.org/plugins/woocommerce/

  2. Roy Ho
    Member
    Posted 11 months ago #

    Not exactly sure what you mean. What files are you referring to?

  3. apcgallery
    Member
    Posted 11 months ago #

    I'd be interested in this too.

    I'm pretty sure the process to remove requests/functionality [per page] for Woocommerce is the same for many other plugins too.

    Instead of focusing only on Woocommerce, try broadening your search query to something like "block wordpress plugin requests". It may take some digging.

    I'd help you in your search, but I'm working on some other site issues at the moment :/

    Good luck, and let me/us know if you find anything!

  4. Waup
    Member
    Posted 11 months ago #

    @slashingpixels - will try to clarify. When testing homepage and other pages load times on pingdom, I see that woocommerce adds many html requests and file kb's, impacting load speed. I only want requests to run if someone's clicks on a Woo-Store page URL.

    @apcgallery - good idea and thanks for the suggestion. Will broaden and report back.

  5. Roy Ho
    Member
    Posted 11 months ago #

    Well first of all don't use pingdom as it is the worse testing site ever. Pingdom loads everything! Do a search on Google about pingdom and you will see several indepths article on how inaccurate pingdom is.

    The other thing is if having WooCommerce activated and loading some assets on pages that are not e-commerce is causing your page to slow down where you notice, then I would suggest changing host. As it should not impact your site to a point where you will know the difference with naked eye.

    On the other hand if you are keen to not load any assets from WooCommerce unless on a actual e-commerce page, you can do that as well.

    You can do a conditional check, probably something like this.

    if ( ! is_woocommerce() ) {
    wp_dequeue_script( 'woocommerce' );
    }

    There are other scripts you can add to that list to remove from. Checkout the woocommerce.php file in the plugin.

  6. Waup
    Member
    Posted 11 months ago #

    Thks Roy. I experimented but couldn't get that making a difference

    Should that conditional check be put in woocommerce.php, functions.php or elsewhere?

  7. Roy Ho
    Member
    Posted 11 months ago #

    Your theme's functions.php file.

  8. Waup
    Member
    Posted 11 months ago #

    thanks, tried that... didn't work unfortunately.

  9. Roy Ho
    Member
    Posted 11 months ago #

    It most absolutely will work...how did you determine it didn't work? Did you look at the page source?

  10. Roy Ho
    Member
    Posted 11 months ago #

    You can also try this...

    add_action( 'wp_enqueue_scripts', 'my_remove_scripts', 999 );
    
    function my_remove_scripts() {
    	if ( ! is_woocommerce() )
    		wp_dequeue_script( 'woocommerce' );
    }

    But take note that there may be other JS that depends on what you're removing so you may need to remove those too...As I stated in my comments earlier in this thread.

  11. ric668
    Member
    Posted 8 months ago #

    @msite, were you able to find out the solution? I am also looking for a solution to stop loading all woocommerce script on home page, but so far haven't figure it out.

  12. esmi
    Forum Moderator
    Posted 8 months ago #

    @ric668: As per the Forum Welcome, please post your own topic.

Reply

You must log in to post.

About this Plugin

About this Topic