WordPress Load Order: A Step-by-Step Guide to the Boot Process
Master the WordPress load order to troubleshoot faster and optimize site performance. Learn exactly how files like wp-settings.php initialize your site.

When I first started building on WordPress, I treated the boot process like a black box. I’d drop code into functions.php, hope it ran at the right time, and occasionally spend three hours debugging why my filter wasn't catching an early-loaded plugin's output. If you want to move beyond basic site building, you need to understand how the engine actually starts.
The WordPress load order isn't just academic trivia; it’s the difference between a performant site and a bloated one that hits its memory limit before the main query even runs.
The Entry Point: wp-load.php
Every request starts the same way. Whether it’s a REST API call, an admin dashboard visit, or a front-end page load, the server hits index.php. From there, it quickly hands off to wp-blog-header.php, which calls wp-load.php.
wp-load.php is the gatekeeper. Its primary job is to find and load wp-config.php. If you’ve ever wondered why your database constants are available everywhere, it’s because this file defines them early. If wp-config.php isn't found, WordPress assumes it needs to trigger the installation process.
The Heavy Lifting: wp-settings.php

Once the environment is configured, we move to wp-settings.php. This is the meat of the WordPress initialization. When you're debugging, this is where you'll spend most of your time.
Here is roughly what happens inside wp-settings.php in order:
- Environment Setup: Sets up global variables, constants, and the
wp_die()handler. - Library Loading: Loads core files like
class-wp-hooks.phpandplugin.php. - Must-Use Plugins: Loads any files inside
/wp-content/mu-plugins/. This happens before standard plugins, which is why I use this directory for site-specific functionality that absolutely cannot be disabled. - Database Connection: Establishes the connection using
$wpdb. - Standard Plugins: Loops through the active plugins and includes them.
- Pluggable Functions: Loads
pluggable.php. These are functions you can override in your themes or plugins because they are wrapped inif ( ! function_exists( ... ) )checks.
If you’re struggling with slow TTFB (Time to First Byte), looking at how many plugins get initialized here is your first step. If you're doing heavy lifting, consider WordPress background processing: Scaling Jobs in Headless WP to move non-essential tasks out of this synchronous boot flow.
The Hook Architecture
WordPress doesn't just run top-to-bottom; it fires hooks. Understanding the sequence of these hooks is how you control the execution.
muplugins_loaded: The earliest hook for your custom code.plugins_loaded: All plugins are loaded and initialized.setup_theme: The theme’sfunctions.phpfile is loaded.after_setup_theme: The theme is fully loaded; images sizes and menus are defined here.init: The big one. The user is authenticated, and the site is ready for most tasks.wp_loaded: Everything is fully loaded.
I once spent an entire afternoon trying to modify a global variable that hadn't been defined yet because I was hooking into init instead of after_setup_theme. It’s a common trap. When you're dealing with assets, remember that Enqueuing scripts and styles the correct way in WordPress relies on the wp_enqueue_scripts hook, which fires much later in the lifecycle.
Optimization Strategies
If your site is dragging, you don't need more hardware—you need to trim the boot process. Every plugin you activate adds overhead to the wp-settings.php loop.
I usually look at these three areas:
- Object Caching: Use persistent caching to avoid re-calculating options on every request. I've written extensively on WordPress object caching optimization: A guide for senior engineers because it's the single most effective way to keep the boot process snappy.
- Autoloading: Check your
wp_optionstable for massive rows withautoloadset toyes. This data is loaded into memory on every single page load. - Conditional Loading: Only load your heavy assets or logic when the specific page or condition is met. Don't load a full CRM integration on the contact page if it's only needed for the dashboard.
FAQ
Why should I use mu-plugins instead of a regular plugin?
mu-plugins are loaded before standard plugins and cannot be deactivated from the dashboard. It’s perfect for core business logic that the site requires to function.
Can I stop WordPress from loading specific core files? Not easily, and usually you shouldn't. If you find yourself wanting to hack core to improve performance, you're likely better off looking at your database queries or object caching strategy first.
Where is the best place to redirect a user based on their role?
Always wait for the template_redirect hook. By this point, the user is fully authenticated and the query has been parsed, so you have full context to make a decision.
Final Thoughts

The WordPress boot process is reliable, but it is synchronous. Every line of code added during initialization adds a tax to your TTFB. Next time you're frustrated by a slow site, try adding a simple timer in mu-plugins to see exactly which hook is taking the longest. You’ll be surprised how often a single, poorly written plugin hook is the culprit. I’m still experimenting with caching the entire wp-settings.php environment for high-traffic sites, but that’s a dangerous game that often causes more cache-invalidation headaches than it's worth. Proceed with caution.
