HBMHBM Rocket
ALL DOCS
DOCUMENTATION

Optimization rules

9 MIN READ

Every optimization HBM Rocket performs, what it does, why it does it, and how to override the default.

Critical CSS

For each detected template kind, HBM Rocket renders the page in headless Chrome at the mobile viewport (412 by 823, DPR 1.75) and extracts the CSS rules that match elements above the fold. The bundle is inlined in the document head. The full stylesheet is deferred behind a tiny preload hint.

Per template detection

Templates are detected automatically: home, page, post, and archive ship out of the box. Custom post types are auto-detected from the WordPress agent on first heartbeat.

Regeneration cadence

  • Weekly, every Sunday at 03:00 UTC
  • On switch_theme events from the agent
  • On upgrader_process_complete events when a plugin or theme updates
  • Manually via the Reoptimize button on the site detail page

Unused CSS removal

Coverage is captured during the same headless render that produces critical CSS. Selectors that match nothing on any sampled page are moved to a separate sheet that loads after first paint, or stripped entirely if confidence is high.

On Elementor and Premium Addons heavy sites, this removes 40 to 70 percent of the CSS payload. The dashboard shows a before and after byte count on each regeneration.

JavaScript delay until interaction

The plugin rewrites <script> tags whose src matches a delay keyword. Rewritten scripts have type="hbm/rocket-delay" and do not execute on load. A small runtime listens for the first scroll, click, keydown, touchstart, or mousemove event and replaces the placeholder tags with real <script> tags.

Default delay list

gtag, gtm, google-analytics, googletagmanager
fbevents, connect.facebook
hotjar, clarity.ms
intercom, tawk.to, crisp.chat, drift.com
leadsie, leadboxer, pinterest

Override per site

Use the hbm_rocket_delay_keywords filter to add or remove entries.

add_filter('hbm_rocket_delay_keywords', function ($list) {
  $list[] = 'klaviyo';
  $list[] = 'sumome';
  return array_diff($list, ['hotjar']);
});

Image optimization

Format negotiation

imgproxy receives requests through Cloudflare or your CDN, sniffs the Accept header, and serves AVIF to capable browsers, WebP to the rest, falling back to original JPEG/PNG only when both are unsupported.

Adaptive sizing

WordPress core srcset is preserved. The plugin extends it with imgproxy URLs at common breakpoints, so <img> elements end up with five to seven candidate sources scaled per viewport.

Hero image preload

The first contentful image above the fold is detected during critical CSS extraction and gets a <link rel="preload" as="image"> tag. LCP typically drops 600 to 1200 ms on Elementor builds.

Page cache

The agent stores rendered HTML on disk in wp-content/cache/hbm-rocket/. Mobile and desktop are cached separately. Cookie aware bypass excludes logged in users, WooCommerce cart and checkout, and any URL marked dynamic via filter.

Cache invalidation graph

When save_post fires, we purge:

  • The post URL itself
  • Every category page that contains it
  • Every tag page that contains it
  • The homepage if the post is recent enough to appear there
  • The RSS feed and main sitemap
  • If Cloudflare integration is connected: the same set at the edge

Self heal

An hourly job compares the latest audit score to the site target. If it is below by more than the configured threshold (5 points by default), the worker:

  • Regenerates critical CSS
  • Purges page cache
  • Warms cache from sitemap
  • Re-runs Lighthouse

An alert is opened only if the second audit is also below target.

Optimization rules | HBM Rocket