WooCommerce – really slow wc_get_product_class

In my investigation and work to make WooCommerce perform a little bit better i found this little surprise! The little helper wc_get_product_class to print correct class names in the wrapper element in html for me took over 100ms per product. With over 100 products it’s really bad! I have quite complex products with many variations. But REALLY slowing down.

So this little code is now removed from my code.

wc_get_product_class('my-product', $product)

Yes, for me this was a good solution. I just added “product” as class instead. And saved 100ms per product! Good enough for my purpose, but it might not be sufficient for everyone.

If you don’t overwrite the product with a template, here is one way that might help you override this:

add_filter( 'woocommerce_attribute_taxonomies', 'remove_slowdowns_caused_by_taxonomies', 10, 1); function remove_slowdowns_caused_by_taxonomies($attribute_taxonomies){ return array('product'); }

Or read more here for more solutions:

https://github.com/woocommerce/woocommerce/issues/20262

Comments

Cart
Sign in
Loading...