Booting WordPress in 10ms: Using SHORTINIT for Ultra-Light Scripts

Table of Contents

WordPress is powerful—but it’s also heavy.

Even the simplest request loads plugins, themes, translations, hooks, and a large portion of core. For many use cases, that’s unnecessary overhead.

This is where SHORTINIT comes in.

SHORTINIT allows you to partially boot WordPress, loading only the minimal core required—often reducing execution time dramatically.

What is SHORTINIT?

SHORTINIT is a constant that tells WordPress to stop loading early in the boot process.

PHP
<?php
define( 'SHORTINIT', true );
require_once __DIR__ . '/wp-load.php';

When enabled, WordPress loads only a subset of core files and skips most of its normal initialization pipeline.

What Loads vs What Doesn’t

✅ What DOES Load

  • Basic constants
  • Database access ($wpdb)
  • Core utility functions
  • Minimal environment setup

❌ What DOES NOT Load

  • Plugins (including MU plugins)
  • Themes
  • Rewrite rules
  • Query system (WP_Query)
  • Hooks like init, wp_loaded
  • Authentication system
  • REST API

Important: This is not “light WordPress”—it’s a barebones core layer.

Performance Comparison

PHP
// Normal WordPress load
~100300ms

// SHORTINIT load
~515ms

The exact numbers depend on hosting, but the difference is often massive.

Basic Example: Fast Database Query Endpoint

PHP
<?php

define( 'SHORTINIT', true );
require_once __DIR__ . '/wp-load.php';

global $wpdb;

$result = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts}");

header('Content-Type: application/json');
echo json_encode([
    'post_count' => (int) $result
]);

This runs without loading plugins or themes—making it extremely fast.

Use Cases for SHORTINIT

1. Internal APIs

When you need fast endpoints without REST API overhead.

2. Cron Jobs

PHP
<?php

define( 'SHORTINIT', true );
require_once __DIR__ . '/wp-load.php';

// perform cleanup
global $wpdb;
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_%'");

3. CLI Tools

Custom scripts interacting with the database or basic WordPress config.

4. Health Checks

Fast monitoring endpoints without full application load.

Advanced Example: Manual User Lookup

Since user APIs are not loaded, you must query manually:

PHP
<?php

define( 'SHORTINIT', true );
require_once __DIR__ . '/wp-load.php';

global $wpdb;

$user = $wpdb->get_row(
    $wpdb->prepare(
        "SELECT ID, user_email FROM {$wpdb->users} WHERE user_login = %s",
        'admin'
    )
);

echo json_encode($user);

Limitations (Critical to Understand)

1. No Plugin System

Any logic relying on plugins will not work.

2. No Hooks

Hooks like init or plugins_loaded never fire.

3. No Authentication

You cannot rely on WordPress login/session APIs.

4. No REST API

You must build your own endpoints.

5. Limited Core Functions

Many helper functions are unavailable unless manually included.

Extending SHORTINIT (Selective Loading)

You can manually include specific parts of WordPress:

PHP
<?php

define( 'SHORTINIT', true );
require_once __DIR__ . '/wp-load.php';

// manually load pluggable functions
require_once ABSPATH . WPINC . '/pluggable.php';

// now you can use some auth functions
if ( \is_user_logged_in() ) {
    echo "User is logged in";
}

This allows a hybrid approach—still fast, but slightly more capable.

When NOT to Use SHORTINIT

  • Building full frontend pages
  • When plugin logic is required
  • When hooks or filters are needed
  • Complex business logic relying on WP APIs

SHORTINIT is best for controlled, minimal tasks.

Key Insight

SHORTINIT is not just a performance trick—it’s a way to treat WordPress as a library rather than a full application.

Once you understand this, you can build:

  • Ultra-fast endpoints
  • Background workers
  • Custom integrations

FAQ

What is SHORTINIT in WordPress?

SHORTINIT is a constant that allows partial WordPress loading, skipping plugins, themes, and most core systems for faster execution.

How much faster is SHORTINIT?

It can reduce load times from ~100ms+ to under 15ms depending on the environment.

Can I use WordPress functions with SHORTINIT?

Only a limited subset. Additional files must be manually included for extended functionality.

Does SHORTINIT load plugins?

No. Plugins and MU plugins are completely skipped.

Is SHORTINIT safe for production?

Yes, when used carefully for controlled tasks like APIs, cron jobs, or internal tools.

Can I enable authentication with SHORTINIT?

Not by default, but you can manually include required files like pluggable.php.

Final takeaway: If you need WordPress power without WordPress overhead, SHORTINIT is one of the most powerful—and underused—tools available.
← WordPress Hidden Boot Layers: The Parts Nobody Explains From URL to Database: The Full WP_Query Execution Path →
Share this page
Back to top