AJAX & Performance

AJAX Lazy Loading

When AJAX Loading is enabled, the accordion renders only the top-level categories on page load. Child categories are fetched via the WooCommerce REST API the first time a parent is expanded. Subsequent opens use the already-fetched data — no repeated requests.

When to Enable AJAX

  • Your store has 50 or more product categories.
  • Your category tree is 3+ levels deep.
  • Time to First Byte (TTFB) or Largest Contentful Paint (LCP) scores are affected by category data.

For stores with fewer than 50 categories, AJAX adds a small network round-trip overhead without meaningful benefit. Leave it disabled for small catalogs.

Transient Caching

Category data is cached in WordPress transients (wp_options) after the first load. The cache is automatically cleared when:

  • A product category is created, updated, or deleted.
  • A product is published or trashed (changes category counts).
  • The cache duration expires.

The default cache duration is 60 minutes. You can adjust it — or disable caching entirely by setting it to 0 — in WooCommerce → Category Accordion → Advanced.

Conditional Asset Loading

When enabled, the plugin’s CSS and JavaScript files are only enqueued on pages that actually contain the accordion — detected via the shortcode, block, or widget. This means shop pages without the accordion do not load any WCA assets at all.

Enable this in WooCommerce → Category Accordion → Advanced → Conditional Asset Loading.

SVG Icons

WCA v3 uses inline SVG for all toggle icons. Compared to loading Font Awesome (used by many older plugins), this saves approximately 116KB per page — without any CDN or preload needed.

Performance Tips

  • Enable transient caching and set a generous cache duration (60–120 minutes) for busy stores.
  • Enable conditional asset loading if the accordion only appears on some pages.
  • Enable AJAX loading only if you have a large category tree.
  • Use max_depth to limit the rendered tree — fewer DOM nodes mean faster paint times.
  • Combine with a full-page caching plugin (WP Rocket, LiteSpeed Cache, etc.) for maximum benefit.

Code Snippets

Enable AJAX via shortcode SHORTCODE
[WC-Category-Accordion ajax="yes"]
Clear all WCA transients via WP-CLI BASH
wp transient delete --search="wca_" --all

Frequently Asked Questions