Title: Do not load javascript when not needed
Last modified: May 23, 2024

---

# Do not load javascript when not needed

 *  Resolved [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * (@mattpramschufer)
 * [2 years ago](https://wordpress.org/support/topic/do-not-load-javascript-when-not-needed/)
 * Hey there,
 * We are running into a conflict with other plugins because of the Select2 library.
   I see that no matter what ProfilePress includes the JS on every page even though
   its not being used 99% of the time. Is there a way to get an option in the upcoming
   version to dequeue scripts on frontend when not in use?
 * You somewhat do that now, but only for your frontend.js file. You load
 *     ```wp-block-code
           wp_enqueue_script('ppress-flatpickr', PPRESS_ASSETS_URL . '/flatpickr/flatpickr.min.js', array('jquery'), PPRESS_VERSION_NUMBER);
   
           wp_enqueue_script('ppress-select2', PPRESS_ASSETS_URL . '/select2/select2.min.js', array('jquery'), PPRESS_VERSION_NUMBER);
       ```
   
 * no matter what

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Collins Agbonghama](https://wordpress.org/support/users/collizo4sky/)
 * (@collizo4sky)
 * [2 years ago](https://wordpress.org/support/topic/do-not-load-javascript-when-not-needed/#post-17776871)
 * See this post [https://profilepress.com/disable-css-and-javascript-wordpress/](https://profilepress.com/disable-css-and-javascript-wordpress/)
   where we documented code snippets to disable/remove javascript/css files you 
   don’t need.
 *  Thread Starter [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * (@mattpramschufer)
 * [2 years ago](https://wordpress.org/support/topic/do-not-load-javascript-when-not-needed/#post-17776887)
 * Oh rock on! Thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Do not load javascript when not needed’ is closed to new replies.

 * ![](https://ps.w.org/wp-user-avatar/assets/icon-256x256.png?rev=2532486)
 * [Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress](https://wordpress.org/plugins/wp-user-avatar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-user-avatar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-user-avatar/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-user-avatar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-user-avatar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-user-avatar/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Matt Pramschufer](https://wordpress.org/support/users/mattpramschufer/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/do-not-load-javascript-when-not-needed/#post-17776887)
 * Status: resolved