Elite WooCommerce Tips & Tricks for Developers
- Updated: May 10, 2026
- Reading Time: 7 mins
1. Disable Cart Fragments AJAX
WooCommerce calls get_refreshed_fragments on every page load to update the cart menu. This is a major resource hog that increases TTFB. Disabling it forces the cart to update only on the cart page.
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_script( 'wc-cart-fragments' );
}, 11 );
2. Dequeue WooCommerce Assets on Non-Shop Pages
By default, WooCommerce loads its CSS and JS on every page, including your blog and home. This code ensures scripts only load on essential store-related pages.
add_action( 'wp_enqueue_scripts', function() {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_script( 'woocommerce' );
}
}, 99 );
3. Disable Marketplace Suggestions
WooCommerce displays “helpful” suggestions for paid extensions in the admin dashboard. This creates unnecessary background requests to the WooCommerce servers, slowing down your backend.
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false' );
4. Remove Product Schema for Non-Product Pages
WooCommerce adds structured data (Schema) to your site. To keep things lean, you should prevent it from injecting product schema into pages that aren’t single products.
add_action( 'wp_footer', function() {
if ( ! is_product() ) {
remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 );
}
});
5. Disable WooCommerce Block Styles
If you are using a custom procedural theme or the classic editor, the heavy CSS file for WooCommerce Gutenberg blocks is dead weight in your header.
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'wc-blocks-style' );
}, 100 );
6. Limit WooCommerce Transients
WooCommerce stores a lot of temporary data (transients) in the options table. Regularly cleaning or limiting these prevents the database from slowing down during high-traffic sales.
// Use this as a one-time clean-up or cron job
wc_delete_product_transients();
7. Disable Default WooCommerce Breadcrumbs
Many developers prefer custom breadcrumbs for better SEO and design. Disabling the native function stops the unnecessary calculation of breadcrumb paths on every page load.
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
8. Remove “Choose an Option” AJAX for Variations
On product pages with many variations, WooCommerce can lag when selecting options. Using this filter helps streamline how variation data is loaded for the user.
add_filter( 'woocommerce_ajax_variation_threshold', function() {
return 50; // Increases threshold before switching to AJAX
});
9. Dequeue Password Strength Meter
WooCommerce loads a heavy zxcvbn.min.js library for password strength. Unless you have a strict membership site, dequeuing this can save a significant script request.
add_action( 'wp_print_scripts', function() {
wp_dequeue_script( 'wc-password-strength-meter' );
}, 100 );
10. Remove Widgets Script
If you aren’t using the WooCommerce Price Filter or layered nav widgets, you can stop the related scripts from loading to reduce the total JS execution time.
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_script( 'wc-price-slider' );
}, 100 );
11. Disable SkyVerge Dashboard Bloat
Many WooCommerce extensions from SkyVerge add extra “Dashboard” menus. This snippet helps keep the admin UI clean and responsive by removing unnecessary menu nodes.
add_action( 'admin_menu', function() {
remove_meta_box( 'wc_admin_dashboard_setup', 'dashboard', 'normal' );
}, 20 );
12. Optimize Product Image Generation
Prevent WooCommerce from generating excess image thumbnails that you don’t use in your design, saving disk space and reducing the overhead of the media library.
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array( 'width' => 150, 'height' => 150, 'crop' => 1 );
});
13. Remove WooCommerce Version from Header
Just like core WordPress, WooCommerce broadcasts its version number. This snippet removes it for security and a cleaner <head> section.
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
14. Disable Cart Redirect After Success
Redirecting to the cart page immediately can add an extra page load for customers who want to keep shopping. Keep them on the same page to improve perceived speed.
update_option( 'woocommerce_cart_redirect_after_add', 'no' );
15. Disable Review Tab (If unused)
If you don’t collect reviews, the review tab requires extra database queries and DOM elements. Remove it to keep product pages lightweight.
add_filter( 'woocommerce_product_tabs', function( $tabs ) {
unset( $tabs['reviews'] );
return $tabs;
}, 98 );
16. Remove Related Products (Clean UI)
Related products increase database queries significantly on high-traffic sites. Disabling them at the code level can speed up the rendering of single product pages.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
17. Increase Heartbeat Interval for WooCommerce
The WooCommerce admin uses the Heartbeat API to track orders. Increasing this interval reduces the load on your server while you are in the backend.
add_filter( 'heartbeat_settings', function( $settings ) {
$settings['interval'] = 120; // 2 minutes
return $settings;
});
18. Disable PhotoSwipe and FlexSlider
If your theme uses custom JS for galleries, you should prevent WooCommerce from loading its default PhotoSwipe and FlexSlider libraries.
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_script( 'flexslider' );
wp_dequeue_script( 'photoswipe-ui-default' );
}, 100 );
19. Optimize Checkout Field Loading
Remove unnecessary checkout fields (like Phone or Company) to reduce the DOM size and make the checkout process faster for the user.
add_filter( 'woocommerce_checkout_fields', function( $fields ) {
unset( $fields['billing']['billing_company'] );
return $fields;
});
20. Force Disable Admin Notes
The WooCommerce admin panel generates a lot of “Notes” and alerts that consume database rows. This helps keep the wp_wc_admin_notes table from expanding indefinitely.
add_filter( 'woocommerce_admin_get_user_data_fields', function( $user_data_fields ) {
return array_diff( $user_data_fields, array( 'extensions_reviews_notices_dismissed' ) );
});
21. Disable Zoom on Product Images
The zoom script is a heavy JS library. If your product images are clear enough, disabling this saves a script execution and improves mobile interaction.
remove_theme_support( 'wc-product-gallery-zoom' );
22. Defer WooCommerce Inline Scripts
WooCommerce injects small snippets of inline JS. Capturing these and deferring them ensures the page renders without waiting for small script executions.
23. Clean Up ‘wc_session’ Table
Automate the removal of old customer sessions that are no longer valid to keep the options table indexed and fast.
// Best handled via a weekly WP-Cron task
WC()->session->cleanup_sessions();
24. Limit Product Query Count on Shop Page
Reducing the number of products per page reduces the number of database calls and image requests per load.
add_filter( 'loop_shop_per_page', function() { return 12; }, 20 );
25. Disable WooCommerce Status Meta Box
The status widget on the WP dashboard calculates total sales and orders every time you log in. Disabling it speeds up the admin home experience.
add_action( 'wp_dashboard_setup', function() {
remove_meta_box( 'woocommerce_dashboard_status', 'dashboard', 'normal' );
});
26. Optimize Product Category Counters
Calculating product counts for every category in a sidebar can be slow. Use code to cache these counts or disable them if not needed.
add_filter( 'woocommerce_rating_filter_count', '__return_false' );
27. Strip WooCommerce CSS Variables
আধুনিক WooCommerce প্রতিটি পেজের হেডার সেকশনে কয়েকশো CSS ভেরিয়েবল (Colors, Spacing, Typography) ইনজেক্ট করে। আপনি যদি কাস্টম থিম ব্যবহার করেন যেখানে আপনি নিজস্ব স্টাইল ব্যবহার করছেন, তবে এই এক্সট্রা কোডগুলো রিমুভ করে হেডার ক্লিন রাখতে পারেন।
add_action( 'wp_enqueue_scripts', function() {
// Remove WooCommerce Global Styles and SVG Filters
wp_dequeue_style( 'woocommerce-inline' );
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
}, 20 );
28. Disable ‘Add to Cart’ JS on Simple Products
সাধারণ প্রোডাক্টের ক্ষেত্রে AJAX অ্যাড-টু-কার্ট ফাংশনালিটি চালানোর জন্য WooCommerce আলাদা একটি JS ফাইল লোড করে। আপনি যদি চান কার্টে ক্লিক করলে পেজ একবার রিফ্রেশ হয়ে কার্ট আপডেট হোক (যা সার্ভার প্রসেসিংয়ের জন্য ক্লিন), তবে এই স্ক্রিপ্টটি ডিজেবল করতে পারেন।
add_action( 'wp_enqueue_scripts', function() {
if ( is_product() ) {
wp_dequeue_script( 'wc-add-to-cart' );
}
}, 99 );
29. Disable ‘Recently Viewed’ Functionality
‘Recently Viewed Products’ ফিচারটি প্রতিটি ইউজারের মুভমেন্ট ট্র্যাক করে এবং ডাটাবেসে অনবরত ডাটা রাইট (Write) করতে থাকে। এটি হাই-ট্রাফিক সাইটের জন্য ডাটাবেসকে অনেক স্লো করে দেয়। এই হুকটি সেই ট্র্যাকিং কুয়েরি বন্ধ করে দেয়।
add_action( 'template_redirect', function() {
if ( is_product() ) {
// Stop tracking viewed products to save DB hits
remove_action( 'viwe_product_tracking', 'wc_track_product_view', 20 );
}
}, 5 );
30. Zero-Plugin Shipping Calculation Logic
ভারী কোনো শিপিং প্লাগইন ব্যবহার না করে খুব সিম্পল কোডের মাধ্যমে নির্দিষ্ট কন্ডিশনে (যেমন: শহরের ভেতর বা বাইরে) শিপিং রেট সেট করা সম্ভব। এটি চেকআউট পেজের রেন্ডারিং টাইম অনেক কমিয়ে দেয়।
add_filter( 'woocommerce_package_rates', function( $rates, $package ) {
// Example: Add a simple handling fee without a plugin
foreach ( $rates as $rate_key => $rate ) {
if ( 'flat_rate' === $rate->method_id ) {
$rates[$rate_key]->cost += 10; // Extra 10 unit fee
}
}
return $rates;
}, 10, 2 );
Optimizing WooCommerce is a balancing act between features and performance. By moving away from “black-box” plugins and utilizing these 30 code-based hacks, you ensure that your store remains lean, scalable, and capable of handling massive traffic without crashing. Every millisecond saved at checkout is a direct boost to your conversion rate. Keep your code clean, your database light, and your sales high.