I’ve noticed a random JavaScript function at the end of the source code of my WordPress website.

<script type="text/javascript">
    (function() {
        var request, b = document.body, c="className", cs="customize-support", rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');

                request = true;

        b = b.replace( rcs, ' ' );
        // The customizer requires postMessage and CORS (if the site is cross domain)
        b += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
    }());
</script>

A quick google search lead me to the article below, but I didn’t find it very informative.

wp_customize_support_script()

Does anyone know what exactly this script does, and if it is required?

2 Answers
2

Yes, it is needed. For reference, the function’s description is:

Prints a script to check whether or not the Customizer is supported, and apply either the no-customize-support or customize-support class to the body.

The class names that the function toggles on the body element control whether or not the Customize link in the admin bar is displayed.

Leave a Reply

Your email address will not be published. Required fields are marked *