Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
WordPressJune 21, 20264 min read

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.

WordPressperformancearchitecturewp-settingsengineeringhooksTutorial
Man stepping down mossy stone steps, showcasing outdoor adventure.

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

Multiple aerial work platforms with colorful booms reaching skyward against a cloud-dotted backdrop.

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:

  1. Environment Setup: Sets up global variables, constants, and the wp_die() handler.
  2. Library Loading: Loads core files like class-wp-hooks.php and plugin.php.
  3. 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.
  4. Database Connection: Establishes the connection using $wpdb.
  5. Standard Plugins: Loops through the active plugins and includes them.
  6. Pluggable Functions: Loads pluggable.php. These are functions you can override in your themes or plugins because they are wrapped in if ( ! 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’s functions.php file 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_options table for massive rows with autoload set to yes. 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

Colorful confetti scattered over the word 'Finally' symbolizing celebration or achievement.

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.

Back to Blog

Similar Posts

Close-up of a vintage typewriter with paper labeled Wordpress.
WordPressJune 21, 20264 min read

WordPress object cache: Persistent vs. Non-Persistent Storage Explained

WordPress object cache mastery is key to faster sites. Learn the differences between persistent and non-persistent storage to optimize your database queries.

Read more
Close-up of the word 'metadata' spelled out with wooden Scrabble tiles on a table.
WordPress
June 21, 2026
4 min read

WordPress Database Structure: Understanding Options and Metadata

WordPress database structure demystified. Learn how the wp_options table and WordPress metadata tables manage your site's data for better performance.

Read more
Close-up of a vintage typewriter with a paper displaying 'WordPress', ideal for blogging and writing concepts.
WordPressJune 21, 20264 min read

WordPress Plugin API: How Actions and Filters Actually Execute

Master the WordPress Plugin API by understanding how actions and filters work under the hood. Learn to control hook execution and write cleaner code today.

Read more