Skip to content

Commit

Permalink
Revert "Add console error when web-vitals.js is absent"
Browse files Browse the repository at this point in the history
This reverts commit 4656cbf.
  • Loading branch information
westonruter committed Mar 22, 2024
1 parent 4656cbf commit 6ae5fb0
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions plugins/optimization-detective/detection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,8 @@ function od_get_detection_script( string $slug, OD_URL_Metrics_Group_Collection
*/
$detection_time_window = apply_filters( 'od_detection_time_window', 5000 );

try {
$web_vitals_lib_data = require __DIR__ . '/detection/web-vitals.asset.php';
} catch ( Error $error ) {
$error_message = '[Optimization Detective] ';
$error_message .= sprintf(
/* translators: 1: File path. 2: CLI command. */
__( 'Unable to load %1$s. Please make sure you have run %2$s.', 'optimization-detective' ),
'detection/web-vitals.asset.php',
'`npm install && npm run build:optimization-detective`'
);
if ( WP_DEBUG && WP_DEBUG_DISPLAY ) {
$error_message .= ' ' . __( 'PHP Error:', 'optimization-detective' ) . ' ' . $error->getMessage();
}
return wp_get_inline_script_tag(
sprintf( 'console.error( %s );', wp_json_encode( $error_message ) )
);
}
$web_vitals_lib_src = add_query_arg( 'ver', $web_vitals_lib_data['version'], plugin_dir_url( __FILE__ ) . '/detection/web-vitals.js' );
$web_vitals_lib_data = require __DIR__ . '/detection/web-vitals.asset.php';
$web_vitals_lib_src = add_query_arg( 'ver', $web_vitals_lib_data['version'], plugin_dir_url( __FILE__ ) . '/detection/web-vitals.js' );

$current_url = od_get_current_url();
$detect_args = array(
Expand Down

0 comments on commit 6ae5fb0

Please sign in to comment.