Trying to connect to wordpress MathJax and configure it. Connecting MathJax did not cause any problems. But I can not connect an additional script to configure MathJax. I add to the functions.php file a code for loading a local script containing the settings:
wp_enqueue_script( 'MathJaxConfiguration', get_template_directory_uri() . '/js/MathJaxCfg.js', null, false, false ); In the browser, this script is loaded with the type="text/javascript" attribute, but for MathJax to hook this script the type = attribute must contain the text/x-mathjax-config parameter. To replace the attribute used filter
add_filter( 'script_loader_tag', 'filter_script_MathJax', 10, 3 ); function filter_script_MathJax( $tag, $handle, $src ){ if ( 'MathJaxConfiguration' === $handle ) { return str_replace( 'text/javascript', 'text/x-mathjax-config', $tag ); } return $tag; } The attribute successfully changes, but the script is not executed. In the browser inspector it is displayed. Added to the beginning of the file MathJaxCfg.js alert, with type="text/javascript" alert fulfills, with text/x-mathjax-config not. How to make it all work?