wppaste

Reference › Cost rankings

WordPress 7.1.0PHP 8.44,809 functions ranked

What is expensive in WordPress

Every function in core, ranked by what it costs to call. The unit is the Zend VM instruction, counted from the compiled opcodes, so a number here is the same on any machine that runs the same PHP version. Nothing is timed.

An instruction is not a fixed amount of time, and one database call outweighs a thousand assignments. Read the count as how much work a function does itself, and the tags beside each name for what it reaches. The method is documented in full.

732free: no calls, no I/O
3,203read stored settings
3,462reach the database
109touch the filesystem
88make network calls
39send mail
824scale with input
1,155hand control to plugins

Heaviest single call

Ranked by the most Zend VM instructions one call can execute. This is how much work the function does itself, before it delegates: not a timing, and not a verdict on speed, since a single database call outweighs a thousand assignments.

  1. 1
    wp_default_scripts()

    Registers all WordPress scripts.

    queryoptionhook
    2,372instructions
  2. 2
    wp_print_media_templates()

    Prints the templates used in the media manager.

    queryoptionhookloops
    1,057instructions
  3. 3
    create_initial_post_types()

    Creates the initial post types when 'init' action is fired.

    queryoptionhook
    964instructions
  4. 4
    wp_enqueue_media()

    Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.

    queryoptionhook7 callers
    682instructions
  5. 5
    wp_image_editor()

    Loads the WP image-editing interface.

    queryoptionhook2 callers
    541instructions
  6. 6
    wp_default_styles()

    Assigns default styles to $styles object.

    queryoptionhookloops
    531instructions
  7. 7
    wp_nav_menu_item_post_type_meta_box()

    Displays a meta box for a post type menu item.

    sqlqueryoptionhook
    512instructions
  8. 8
    comment_form()

    Outputs a complete commenting form for use within a template.

    queryoptionhookloops2 callers
    492instructions
Full ranking →

Most hooks fired in one call

Every hook is an opening for third-party code, and nothing in core bounds what that code costs. These are the functions where a slow site is most often not core's fault.

  1. 1
    comment_form()

    Outputs a complete commenting form for use within a template.

    queryoptionhookloops2 callers
    18hooks
  2. 2
    wp_insert_user()

    Inserts a user into the database.

    sqlqueryoptionhookloops4 callers
    18hooks
  3. 3
    wp_insert_post()

    Inserts or updates a post in the database.

    sqlqueryoptionhook21 callers
    16hooks
  4. 4
    wp_update_term()

    Updates term based on arguments provided.

    sqlqueryoptionhook8 callers
    13hooks
  5. 5
    wp_insert_term()

    Adds a new term to the database.

    sqlqueryoptionhook11 callers
    12hooks
  6. 6
    login_header()

    Outputs the login page header.

    queryoptionhookloops
    12hooks
  7. 7
    media_upload_form()

    Outputs the legacy media upload form.

    queryoptionhook1 caller
    10hooks
  8. 8
    wp_mail()

    Sends an email, similar to PHP's mail function.

    mailqueryoptionhook28 callers
    10hooks
Full ranking →

Functions that reach the network

Calling one of these during a page render puts a remote host in your critical path. Ranked by how many places in core call them, because that is how often the cost is paid on your behalf.

  1. 1
    wp_remote_get()

    Performs an HTTP request using the GET method and returns its response.

    http20 callers
    20core callers
  2. 2
    wp_remote_post()

    Performs an HTTP request using the POST method and returns its response.

    http9 callers
    9core callers
  3. 3
    themes_api()

    Retrieves theme installer pages from the WordPress.org Themes API.

    httpqueryoptionhookloops8 callers
    8core callers
  4. 4
    plugins_api()

    Retrieves plugin installer pages from the WordPress.org Plugins API.

    httpqueryoptionhook8 callers
    8core callers
  5. 5
    wp_safe_remote_get()

    Retrieves the raw response from a safe HTTP request using the GET method.

    http8 callers
    8core callers
  6. 6
    wp_safe_remote_request()

    Retrieves the raw response from a safe HTTP request.

    http6 callers
    6core callers
  7. 7
    wp_version_check()

    Checks WordPress version against the newest version.

    httpqueryoptionhookloops5 callers
    5core callers
  8. 8
    wp_update_plugins()

    Checks for available updates to plugins based on the latest versions hosted on WordPress.org.

    httpqueryoptionhook5 callers
    5core callers
Full ranking →

Most distinct cost outcomes

Distinct ways one call can run, each with its own price, recovered from the control-flow graph. A high count means cost depends heavily on arguments and site state, so any single benchmark of these tells you very little.

  1. 1
    upgrade_all()

    Functions to be called in installation and upgrade scripts.

    queryoptionhook1 caller
    4,000outcomes
  2. 2
    wp_hoist_late_printed_styles()

    Adds the hooks needed for CSS output to be delayed until after the content of the page has been established.

    sqlqueryoptionhookloops
    3,006outcomes
  3. 3
    twentyfifteen_entry_meta()

    Prints HTML with meta information for the categories, tags.

    queryoptionhook
    2,740outcomes
  4. 4
    wp_ajax_install_plugin()

    Handles installing a plugin via AJAX.

    httpqueryoptionhook
    2,016outcomes
  5. 5
    switch_theme()

    Switches the theme.

    sqlqueryoptionhook9 callers
    1,912outcomes
  6. 6
    download_url()

    Downloads a URL to a local temporary file using the WordPress HTTP API.

    httpfilesystemqueryoption3 callers
    1,716outcomes
  7. 7
    customize_themes_print_templates()

    Prints JS templates for the theme-browsing UI in the Customizer.

    queryoptionhook
    1,568outcomes
  8. 8
    wp_ajax_install_theme()

    Handles installing a theme via AJAX.

    httpqueryoptionhook
    1,536outcomes
Full ranking →

Most called by core

Cost paid far more often than your own code suggests, because core calls these throughout a request whether or not you do. A change in one of these is felt everywhere.

  1. 1
    get_permalink()

    Retrieves the full permalink for the current post or post ID.

    queryoptionhook50 callers
    50core callers
  2. 2
    update_option()

    Updates the value of an option that was already added.

    sqlqueryoptionhook50 callers
    50core callers
  3. 3
    esc_url()

    Checks and cleans a URL.

    hook50 callers
    50core callers
  4. 4
    get_option()

    Retrieves an option value based on an option name.

    sqlqueryoptionhook50 callers
    50core callers
  5. 5
    add_query_arg()

    Retrieves a modified URL query string.

    hookloops50 callers
    50core callers
  6. 6
    get_bloginfo()

    Retrieves information about the current site.

    queryoptionhook50 callers
    50core callers
  7. 7
    get_term()

    Gets all term data from database by term ID.

    queryoptionhook50 callers
    50core callers
  8. 8
    wp_die()

    Kills WordPress execution and displays HTML page with an error message.

    queryoptionhook50 callers
    50core callers
Full ranking →

Free to call

No calls out, no I/O, constant work. Caching the result of one of these costs more than calling it again.

  1. 1
    block_core_shared_navigation_render_submenu_icon()

    Returns the submenu SVG chevron icon.

    4 callers
    1instructions
  2. 2
    _wp_privacy_action_request_types()

    Gets all personal data request types.

    3 callers
    1instructions
  3. 3
    rest_get_allowed_schema_keywords()

    Get all valid JSON schema properties.

    2 callers
    1instructions
  4. 4
    twentytwenty_get_customizer_color_vars()

    Returns an array of variables for the customizer preview.

    2 callers
    1instructions
  5. 5
    wp_get_layout_definitions()

    Returns layout definitions, keyed by layout type.

    2 callers
    1instructions
  6. 6
    get_shortcode_atts_regex()

    Retrieves the shortcode attributes regex.

    1 caller
    1instructions
  7. 7
    twentynineteen_get_avatar_size()

    Returns the size for avatars used in the theme.

    1 caller
    1instructions
  8. 8
    __return_empty_array()

    Returns an empty array.

    1instructions
Full ranking →