Optimization in Background

MegaOptim makes it easy to bulk optimize in background while you are away.

Uncategorized
Darko Gjorgjijoski
by Darko Gjorgjijoski March 14, 2026

You’ve just hit “Optimize All” on a library of 2,000 images. Do you really need to keep that tab open the whole time?

No. MegaOptim keeps working even after you close the page. Here’s what’s happening behind the scenes and one simple tweak that makes it even better.

What Happens When You Stay on the Page

While the MegaOptim page is open, the plugin takes advantage of your browser to process images as fast as possible. You’ll see a live progress bar, and images are handled quickly because the browser is actively driving the work.

This is the fastest way to optimize, but it’s not the only way.

What Happens When You Leave

Close the tab, switch to another page, or shut your laptop, it doesn’t matter. MegaOptim hands off the remaining work to WordPress’s built-in task scheduler (WP-Cron), and processing continues on its own.

Your images will keep getting optimized whether you’re logged in or not. Come back an hour later and you’ll find the batch has been chugging along without you.

The One Catch With WP-Cron

WordPress doesn’t have a real background scheduler. Instead, WP-Cron piggybacks on site visits — every time someone loads a page on your site, WordPress checks if there are any scheduled tasks to run.

For most sites, this works fine. But if your site doesn’t get much traffic (or you’re working on a staging site), scheduled tasks can stall simply because nobody is visiting.

This is easy to fix.

Switch to a Real System Cron (Recommended)

A system cron runs on a fixed schedule set by your server, regardless of whether anyone visits your site. Setting one up takes about two minutes and makes background processing completely reliable.

Step 1: Tell WordPress to Stop Using WP-Cron

Add this line to your wp-config.php, before “That’s all, stop editing!”:

define('DISABLE_WP_CRON', true);

This also gives your visitors a tiny speed boost since WordPress no longer checks for tasks on every page load.

Step 2: Add a Cron Job on Your Server

Choose whichever method matches your hosting setup:

cPanel:

  1. Go to cPanel > Cron Jobs
  2. Set the interval to every minute (or every 5 minutes)
  3. Use this command:
/usr/local/bin/php /path/to/your/wordpress/wp-cron.php >/dev/null 2>&1

Replace /path/to/your/wordpress/ with your actual WordPress directory.

SSH / Terminal:

crontab -e

Then add:

* * * * * /usr/local/bin/php /path/to/your/wordpress/wp-cron.php >/dev/null 2>&1

WP-CLI:

* * * * * cd /path/to/your/wordpress && wp cron event run --due-now >/dev/null 2>&1

How to Tell It’s Working

Start a bulk optimization, close the tab, and check back in a few minutes. If the progress has moved forward, you’re all set.

When Does This Matter Most?

For a blog with 50 images, WP-Cron is perfectly fine. But if you’re optimizing a large media library with hundreds or thousands of images, a system cron makes a real difference:

  • Processing keeps moving overnight or over the weekend
  • You don’t need to keep a tab open or worry about traffic
  • Large batches finish predictably instead of stalling on quiet days

Quick Reference

ScenarioProcessing SpeedNeed to Keep Tab Open?
Page open in browserFastestYes
Page closed, system cron activeSteadyNo
Page closed, WP-Cron onlyDepends on trafficNo

For the fastest results, keep the page open. For hands-off processing, set up a system cron and let MegaOptim take care of the rest.

Leave a reply