Title: Enqueue scripts on demand
Last modified: May 31, 2018

---

# Enqueue scripts on demand

 *  [zzhovo](https://wordpress.org/support/users/zzhovo/)
 * (@zzhovo)
 * [8 years ago](https://wordpress.org/support/topic/enqueue-scripts-on-demand/)
 * There’s a check role_can_impersonate() before drawing the menu, so the same check
   can be used to avoid loading scripts.
 *     ```
       function tikemp_scripts(){
       	if( role_can_impersonate( ) ){
       		wp_enqueue_script('tikemp_search_scroll', plugins_url( '/js/jquery.nicescroll.min.js', __FILE__ ), array( 'jquery' ),'1.1',true);
       		wp_enqueue_script('tikemp_script', plugins_url( '/js/script.js', __FILE__ ), array( 'jquery','tikemp_search_scroll' ),'1.2',true);
       	}
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  [tamim71](https://wordpress.org/support/users/tamim71/)
 * (@tamim71)
 * [8 years ago](https://wordpress.org/support/topic/enqueue-scripts-on-demand/#post-10369203)
 * Hi [@zzhovo](https://wordpress.org/support/users/zzhovo/),
 * Thanks for suggestion. We will add this in next update
 * Thanks,
    Tamim

Viewing 1 replies (of 1 total)

The topic ‘Enqueue scripts on demand’ is closed to new replies.

 * ![](https://ps.w.org/fast-user-switching/assets/icon.svg?rev=1736245)
 * [Fast User Switching](https://wordpress.org/plugins/fast-user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fast-user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fast-user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/fast-user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fast-user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fast-user-switching/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [tamim71](https://wordpress.org/support/users/tamim71/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/enqueue-scripts-on-demand/#post-10369203)
 * Status: not resolved