You can remove specific styles and java scripts for specific page template like below. Add the code into the functions.php
file of your current theme. To see the list of all JS and CSS you may want to use a plugin like this: https://wordpress.org/plugins/debug-bar-list-dependencies/
/**
* Remove specific java scripts.
*/
function se_remove_script() {
if ( is_page_template( 'blankPage.php' ) ) {
wp_dequeue_script( 'some-js' );
wp_dequeue_script( 'some-other-js' );
}
}
add_action( 'wp_print_scripts', 'se_remove_script', 99 );
/**
* Remove specific style sheets.
*/
function se_remove_styles() {
if ( is_page_template( 'blankPage.php' ) ) {
wp_dequeue_style( 'some-style' );
wp_dequeue_style( 'some-other-style' );
}
}
add_action( 'wp_print_styles', 'se_remove_styles', 99 );
You can remove all styles and java scripts in one go for specific page template like below. Add the code into the functions.php
file of your current theme.
/**
* Remove all java scripts.
*/
function se_remove_all_scripts() {
global $wp_scripts;
if ( is_page_template( 'blankPage.php' ) ) {
$wp_scripts->queue = array();
}
}
add_action( 'wp_print_scripts', 'se_remove_all_scripts', 99 );
/**
* Remove all style sheets.
*/
function se_remove_all_styles() {
global $wp_styles;
if ( is_page_template( 'blankPage.php' ) ) {
$wp_styles->queue = array();
}
}
add_action( 'wp_print_styles', 'se_remove_all_styles', 99 );