Question

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

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

https://developer.wordpress.org/reference/functions/wp_customize_support_script/

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

Was it helpful?

Solution

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.

OTHER TIPS

I had the same problem and finally found the fix.

In my case tag was missing the ">" at the end.

<body <?php body_class(); ?>>

instead of:

<body <?php body_class(); ?> 

Maybe this will help anyone else.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top