Skip to content

Commit

Permalink
Theme: Dequeue Sensei course archive JS
Browse files Browse the repository at this point in the history
Not required and allows jQuery loading to be deferred.

Fixes #2679
  • Loading branch information
adamwoodnz committed Sep 3, 2024
1 parent 819656a commit 539720f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wp-content/themes/pub/wporg-learn-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 539720f

Please sign in to comment.