diff --git a/wp-content/themes/pub/wporg-learn-2024/functions.php b/wp-content/themes/pub/wporg-learn-2024/functions.php index 94bc8180e..52157306e 100644 --- a/wp-content/themes/pub/wporg-learn-2024/functions.php +++ b/wp-content/themes/pub/wporg-learn-2024/functions.php @@ -38,6 +38,7 @@ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\maybe_enqueue_sensei_assets', 100 ); // Attached at 11 to run after scripts are registered, but before they are enqueued. add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\defer_scripts', 11 ); +add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\remove_sensei_course_archive_js', 100 ); // Remove Jetpack CSS on frontend add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 ); @@ -251,6 +252,19 @@ function defer_scripts() { } } +/** + * Remove Sensei course archive JavaScript for performance. + * Not needed as we don't display Sensei course order controls. + */ +function remove_sensei_course_archive_js() { + if ( is_admin() || ! is_post_type_archive( 'course' ) ) { + return; + } + + wp_dequeue_script( 'sensei-course-archive-js' ); + wp_deregister_script( 'sensei-course-archive-js' ); +} + /** * Dequeue Sensei video scripts loaded on lessons archive. * Sensei LMS and Sensei Pro both enqueue video player scripts for lesson posts,