Title: _wp_customize_loader_settings
Published: April 25, 2014
Last modified: May 20, 2026

---

# _wp_customize_loader_settings()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#wp--skip-link--target)

Adds settings for the customize-loader script.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#source)󠁿

    ```php
    function _wp_customize_loader_settings() {
    	$admin_origin = parse_url( admin_url() );
    	$home_origin  = parse_url( home_url() );
    	$cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );

    	$browser = array(
    		'mobile' => wp_is_mobile(),
    		'ios'    => wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ),
    	);

    	$settings = array(
    		'url'           => esc_url( admin_url( 'customize.php' ) ),
    		'isCrossDomain' => $cross_domain,
    		'browser'       => $browser,
    		'l10n'          => array(
    			'saveAlert'       => __( 'The changes you made will be lost if you navigate away from this page.' ),
    			'mainIframeTitle' => __( 'Customizer' ),
    		),
    	);

    	$script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';';

    	$wp_scripts = wp_scripts();
    	$data       = $wp_scripts->get_data( 'customize-loader', 'data' );
    	if ( $data ) {
    		$script = "$data\n$script";
    	}

    	$wp_scripts->add_data( 'customize-loader', 'data', $script );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/theme.php#L3729)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/theme.php#L3729-L3758)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Scripts::add_data()](https://developer.wordpress.org/reference/classes/wp_scripts/add_data/)`wp-includes/class-wp-scripts.php` |

This overrides the add_data method from [WP_Dependencies](https://developer.wordpress.org/reference/classes/wp_dependencies/), to support normalizing of $args.

  | 
| [wp_scripts()](https://developer.wordpress.org/reference/functions/wp_scripts/)`wp-includes/functions.wp-scripts.php` |

Initializes $wp_scripts if it has not been set.

  | 
| [wp_is_mobile()](https://developer.wordpress.org/reference/functions/wp_is_mobile/)`wp-includes/vars.php` |

Test if the current browser runs on a mobile device (smart phone, tablet, etc.).

  | 
| [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)`wp-includes/functions.php` |

Encodes a variable into JSON, with some confidence checks.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_customize_loader_settings/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_customize_loader_settings%2F)
before being able to contribute a note or feedback.