BD Speed Optimizer

Optimization Settings & Database Cleanup

Updated March 9, 2026 7 min read

Frontend Optimization Settings

All frontend optimization toggles are found on the BD Speed → Settings tab. They are organized into four cards: JavaScript, HTML & Media, Cleanup, and Resource Hints.

License requirement: These optimizations are only applied to your live site when you have an active license. Without a license, you can toggle them on and off in the admin, but they will not execute on the frontend. The plugin checks BDSO_License::is_active() before initializing any optimizations. It also skips optimization on admin pages, AJAX requests, and cron execution.

JavaScript Optimizations

Defer JavaScript Loading

Setting key: defer_js

Adds the defer attribute to script tags, which tells the browser to download scripts in parallel with HTML parsing and execute them after the document has finished parsing.

Exclusions:

  • jquery-core and jquery — many plugins depend on jQuery being available immediately
  • WooCommerce scripts (handles starting with wc- or woocommerce) — required for product pages, cart, and checkout
  • Scripts that already have defer or async attributes

How it works: The plugin hooks into the script_loader_tag filter at priority 10 and replaces src= with defer src= in the script tag HTML.

Delay JS Execution

Setting key: delay_js

A more aggressive optimization than defer. Instead of just deferring download, it completely prevents scripts from loading until the user first interacts with the page. This dramatically improves initial page load metrics like Time to Interactive (TTI) and Largest Contentful Paint (LCP).

How it works:

  1. The plugin hooks into script_loader_tag at priority 11 (after defer) and replaces src="..." with data-bdso-src="...".
  2. A small inline loader script is injected in the footer that listens for mouseover, scroll, keydown, and touchstart events.
  3. On the first user interaction (or after a 5-second timeout as a fallback), all scripts with data-bdso-src are replaced with real script elements that trigger loading.

Same exclusions as Defer JS (jQuery core and WooCommerce). If both Defer and Delay are enabled, Delay takes precedence because it runs at a higher filter priority and removes the defer attribute.

Remove jQuery Migrate

Setting key: remove_jquery_migrate

Removes the jQuery Migrate script from jQuery’s dependencies. jQuery Migrate provides backward compatibility for deprecated jQuery functions. Most modern themes and plugins do not need it.

Caution: Only enable this if your theme and plugins do not rely on deprecated jQuery functions. If you see JavaScript errors in the browser console after enabling this, turn it off.

How it works: Hooks into wp_default_scripts and removes jquery-migrate from the jquery script’s dependency array.

HTML & Media Optimizations

Minify HTML Output

Setting key: minify_html

Reduces the size of your HTML output by stripping unnecessary whitespace and comments. This can reduce page size by 10–30% depending on your theme.

What it removes:

  • HTML comments (except IE conditional comments like <!--[if IE]>)
  • Extra whitespace between HTML tags (reduced to a single space)
  • Multiple consecutive spaces (collapsed to one)

How it works: Hooks into template_redirect at priority 1 to start output buffering. The buffer callback applies regex-based minification to the complete HTML before it is sent to the browser.

Lazy Load Images

Setting key: lazy_load_images

Adds the native browser loading="lazy" attribute to <img> tags in post content and featured images. This tells the browser to defer loading images that are offscreen until the user scrolls near them.

How it works: Filters the_content and post_thumbnail_html at priority 99. Uses a regex to find <img> tags that do not already have a loading attribute and adds loading="lazy".

Note: WordPress 5.5+ adds loading="lazy" natively to many images. This setting catches any images that WordPress missed.

Lazy Load Iframes

Setting key: lazy_load_iframes

Adds loading="lazy" to <iframe> tags in post content. This is particularly useful for embedded YouTube videos, Google Maps, and other third-party widgets that can be heavy to load.

How it works: Filters the_content at priority 99. Uses a regex to find <iframe> tags without an existing loading attribute and adds loading="lazy".

Cleanup Optimizations

Disable WordPress Emojis

Setting key: disable_emojis

Removes the WordPress emoji detection script and related styles. WordPress loads an emoji detection script and stylesheet on every page by default, even if you never use emojis. Disabling saves 1–2 HTTP requests and about 16KB of JavaScript.

What it removes:

  • The print_emoji_detection_script action from wp_head
  • The print_emoji_styles action from wp_print_styles
  • Emoji-related filters on content feeds and email
  • The wpemoji TinyMCE plugin
  • The s.w.org emoji CDN DNS prefetch hint

Disable WordPress Embeds

Setting key: disable_embeds

Removes the WordPress oEmbed system, which allows other sites to embed your posts and adds embed-related scripts and discovery links to your pages.

What it removes:

  • The oEmbed REST API route
  • The oEmbed discovery link tags in <head>
  • The wp-embed JavaScript file
  • The wpembed TinyMCE plugin
  • Embed-related rewrite rules

Caution: Only disable this if you do not need other WordPress sites to embed your posts via oEmbed. This does not affect your ability to embed third-party content (YouTube, Twitter, etc.) in your own posts.

Remove Query Strings

Setting key: remove_query_strings

Strips ?ver=X.X.X parameters from CSS and JavaScript file URLs. Many CDNs and proxy caches refuse to cache URLs that contain query strings. Removing them improves cache hit rates.

How it works: Filters style_loader_src and script_loader_src to remove the ver query parameter using remove_query_arg().

Note: After enabling this, you may need to clear your browser cache and any server-side caches to see updated CSS/JS files when plugins or themes update.

Resource Hints

DNS Prefetch Domains

Setting key: dns_prefetch

Pre-resolves DNS for external domains used on your pages. This eliminates the DNS lookup delay when the browser eventually requests resources from those domains.

How to configure: Enter one domain per line (e.g., fonts.googleapis.com, cdn.example.com). The plugin automatically adds // prefix if missing.

Output: Adds <link rel="dns-prefetch" href="//domain.com"> tags to your page head.

Preconnect Domains

Setting key: preconnect_domains

Establishes early connections to critical external origins, including DNS resolution, TCP handshake, and TLS negotiation. More aggressive than DNS prefetch but uses slightly more bandwidth.

How to configure: Enter one domain per line (e.g., fonts.gstatic.com). Best used for domains where you know resources will definitely be loaded.

Output: Adds <link rel="preconnect" href="//domain.com" crossorigin> tags to your page head.

Database Cleanup

The database cleanup tools are accessible from the Scanner tab, below the scan results. They are also functional without a license. Four cleanup actions are available:

Clean Post Revisions

Deletes all post revisions from the wp_posts table and their associated metadata from wp_postmeta. WordPress saves a revision every time you update a post, which can bloat your database over time.

The current revision count is displayed next to the button. The button is disabled when the count is zero.

What it deletes:

  1. All rows from wp_postmeta where the post_id belongs to a revision
  2. All rows from wp_posts where post_type = 'revision'

Note: This action is irreversible. After cleaning revisions, you cannot undo changes using the WordPress revision history. Consider taking a backup before cleaning if you rely on revision history.

Clean Spam/Trash Comments

Deletes all comments marked as spam or trash, along with their associated metadata from wp_commentmeta.

The current count of spam + trash comments is displayed next to the button.

Clean Expired Transients

Deletes expired transients from the wp_options table. Transients are temporary cached values used by WordPress core, themes, and plugins. Expired transients serve no purpose and take up space in the options table.

How it works: The plugin finds all _transient_timeout_* options whose value (a Unix timestamp) is less than the current time, then calls delete_transient() for each one. This properly removes both the timeout entry and the transient value entry.

Optimize Tables

Runs OPTIMIZE TABLE on all WordPress database tables (those matching the configured table prefix). This reclaims unused space, defragments the data file, and sorts indexes — similar to defragmenting a hard drive.

Unlike the other cleanup buttons, this one is always enabled because it is a tune-up operation rather than a count-based cleanup. The button displays the number of tables optimized after completion.

Settings Storage

All settings are stored in a single serialized array under the WordPress option bdso_settings. The complete list of setting keys and their defaults:

Setting KeyTypeDefaultDescription
defer_jsBooleanfalseDefer JavaScript loading
delay_jsBooleanfalseDelay JS until user interaction
remove_jquery_migrateBooleanfalseRemove jQuery Migrate script
minify_htmlBooleanfalseMinify HTML output
lazy_load_imagesBooleanfalseLazy load images
lazy_load_iframesBooleanfalseLazy load iframes
disable_emojisBooleanfalseDisable WordPress emojis
disable_embedsBooleanfalseDisable WordPress embeds
remove_query_stringsBooleanfalseRemove ver= from CSS/JS URLs
dns_prefetchStringEmptyNewline-separated DNS prefetch domains
preconnect_domainsStringEmptyNewline-separated preconnect domains
license_keyStringEmptyLicense key (preserved across saves)
license_emailStringEmptyLicense email (preserved across saves)

Important Compatibility Notes

Caching Plugins

BD Speed Optimizer works alongside caching plugins like LiteSpeed Cache. However, after enabling or disabling optimizations, you should purge your page cache so the changes take effect immediately.

WooCommerce Compatibility

The Defer JS and Delay JS optimizations automatically exclude WooCommerce scripts (handles starting with wc- or woocommerce) to prevent breaking product pages, cart, and checkout functionality.

Frontend-Only Execution

All optimizations run only on the public-facing frontend. They are explicitly skipped on admin pages (is_admin()), during AJAX requests (wp_doing_ajax()), and during cron execution (wp_doing_cron()).

Deactivation

When you deactivate BD Speed Optimizer, all frontend optimizations immediately stop. Your settings are preserved in the bdso_settings option so reactivating the plugin restores your previous configuration. The plugin has no cron hooks or database tables to clean up.