Skip to main content
deleted 1 character in body
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

The best way to avoid CSS/JS conflict between plugins is to enqueue in the right place.

I mean, enqueue the style/script right when the script is needed and not in the registration of the styles/scripts.

function lsmi_load_admin_script() {
    wp_register_style( 'chosencss', plugins_url( 'assets/resources/chosen.min.css', __FILE__ ), true, '', 'all' );
}

add_action( 'wp_enqueue_scripts' , 'lsmi_load_admin_script' );

   /* When you really need the style/script - use it */
  function use_my_style () {
    wp_enqueue_style('chosencss');
  }

This way, if you don't need a style in a certain page, you can do an if/else, according to the page/post that is going to display the style/script

The best way to avoid CSS/JS conflict between plugins is to enqueue in the right place.

I mean, enqueue the style/script right when the script is needed and not in the registration of the styles/scripts.

function lsmi_load_admin_script() {
wp_register_style( 'chosencss', plugins_url( 'assets/resources/chosen.min.css', __FILE__ ), true, '', 'all' );
}

add_action( 'wp_enqueue_scripts' , 'lsmi_load_admin_script' );

   /* When you really need the style/script - use it */
  function use_my_style () {
  wp_enqueue_style('chosencss');
  }

This way, if you don't need a style in a certain page, you can do an if/else, according to the page/post that is going to display the style/script

The best way to avoid CSS/JS conflict between plugins is to enqueue in the right place.

I mean, enqueue the style/script right when the script is needed and not in the registration of the styles/scripts.

function lsmi_load_admin_script() {
    wp_register_style( 'chosencss', plugins_url( 'assets/resources/chosen.min.css', __FILE__ ), true, '', 'all' );
}

add_action( 'wp_enqueue_scripts' , 'lsmi_load_admin_script' );

/* When you really need the style/script - use it */
function use_my_style () {
    wp_enqueue_style('chosencss');
}

This way, if you don't need a style in a certain page, you can do an if/else, according to the page/post that is going to display the style/script

Source Link

The best way to avoid CSS/JS conflict between plugins is to enqueue in the right place.

I mean, enqueue the style/script right when the script is needed and not in the registration of the styles/scripts.

function lsmi_load_admin_script() {
wp_register_style( 'chosencss', plugins_url( 'assets/resources/chosen.min.css', __FILE__ ), true, '', 'all' );
}

add_action( 'wp_enqueue_scripts' , 'lsmi_load_admin_script' );

   /* When you really need the style/script - use it */
  function use_my_style () {
  wp_enqueue_style('chosencss');
  }

This way, if you don't need a style in a certain page, you can do an if/else, according to the page/post that is going to display the style/script