The Symptom

If you are using the WordPress Theme provided by Qode.com called Bridge (V17.0), and you are also using the search engine optimization plug-in from Yoast.com (v9.1) then you may have noticed some JavaScript issues on the Home page of your site.

Specifically, if you are using any Page Transition other than No Animation on the Home page, you may have found a JavaScript error when switching to the Home page from any other menu page in your site.  The error does not occur when you first go to the site.

If you look at your browser’s console you will see an error like  Expected ‘;’ and the loading animation never finishes.  Also any main picture or movie may not show. You may also be unable to use the menu to navigate away from the page you are on.

The Cause

The cause of this problem is the way the Bridge theme loads the page when switching to it when Page Transitions are used.  Instead of a normal page load by the browser, it is loaded by JavaScript and specifically by multiple calls to a jQuery function that uses the exec function.

When the Home page is accessed via the menu from another page, Yoast creates a JavaScript Object.  The code for the object is passed to the exec function as a string, but it should really be an JavaScript object, so the exec function fails with the above-mentioned error.

The string in question in the data variable looks something like this:
{"@context":"https:\/\/schema.org","@type":"WebSite","@id":"#website","url":"http:\/\/www.mysite.com\/","name":"MySite","potentialAction":{"@type":"SearchAction","target":"http:\/\/www.mysite.com\/?s={search_term_string}","query-input":"required name=search_term_string"}}

The function in jquery.js (v1.12.4 Line 342) that tries to execute the string in the data variable looks like this:

globalEval: function( data ) {
if ( data && jQuery.trim( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
} )( data );
}
},

This is not a valid JavaScript string to be executed.  It would only be valid if the data variable was a JavaScript Object defined by such a string.

The Solution

The only practical solution to this problem is to disable the schema.org functionality in the Yoast plug-in, and therefore prevent the string from being created. (Of course, you will lose any functionality that the information to schema.org provided.) There is no place to do this in the User Interface, so some PHP code must be added to functions.php.  Normally you would have created a child theme from the main one, so this file would be in /wp-content/themes/bridge-child folder.

Edit this file and add the following code to the bottom of it:
function disable_yoast_schema_data($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'disable_yoast_schema_data', 10, 1);

Then clear any server and client caches and make sure the problem has been resolved.

A Suggestion To The Theme Developer

The correct solution for Qode to implement would be to detect strings intended to define an object and convert them to one before passing the data variable to jQuery.