Title: Loading scripts only if needed
Last modified: August 30, 2016

---

# Loading scripts only if needed

 *  Resolved [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/loading-scripts-only-if-needed/)
 * Hi !
 * It seems that wppb_animate.js?ver=4.3.1 is loaded even if not needed.
 * Could you make it be loaded only if needed (aka only if the progress bar shortcode
   is used on the page ?)
 * I could use PLugin Organizer to load plugins accordin to certain post, but i 
   think it is better if it is handle right in the plugin.
 * Thanks 🙂
 * [https://wordpress.org/plugins/progress-bar/](https://wordpress.org/plugins/progress-bar/)

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

 *  Plugin Author [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * (@jazzs3quence)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/loading-scripts-only-if-needed/#post-6637057)
 * Created an issue for it on the Github tracker.
 * [https://github.com/jazzsequence/progress-bar/issues/3](https://github.com/jazzsequence/progress-bar/issues/3)
 *  It might be more trouble than it’s worth — the only way you’d know if the shortcode
   was in use on a page would be getting into the_content and checking for the existence
   of the shortcode text (or checking if the widget was being used if you were using
   the sidebar widget). In either case we’re hitting the database on every page 
   load (possibly twice, once for the_content and once for the sidebar) and possibly
   dozens or even hundreds of times if we’re looking at an index or an archive page.
   Not sure that’s worth the small amount of overhead caused by loading the js on
   every page.
 * As a theme developer, if you don’t want it to load on every page, you can easily
   dequeue the js on all pages except those using the shortcode or use some other
   method to more selectively handle loading the js.
 *  Thread Starter [X-Raym](https://wordpress.org/support/users/x-raym/)
 * (@x-raym)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/loading-scripts-only-if-needed/#post-6637064)
 * You are definitely rigth, it could have huge performance issues…
 * It’s ok, i will go with Plugin Organizer 😀
 * Thanks for your support anf expertise !
 *  Plugin Author [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * (@jazzs3quence)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/loading-scripts-only-if-needed/#post-6637096)
 * Yeah, I think it’s easier to tackle the problem from that angle than to try to
   do it within the plugin — I appreciate the sentiment but we’re limited by the
   medium (using a shortcode).
 * Thanks for understanding and glad you like the plugin 😀

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

The topic ‘Loading scripts only if needed’ is closed to new replies.

 * ![](https://ps.w.org/progress-bar/assets/icon-256x256.png?rev=2909774)
 * [Progress Bar](https://wordpress.org/plugins/progress-bar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/progress-bar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/progress-bar/)
 * [Active Topics](https://wordpress.org/support/plugin/progress-bar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/progress-bar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/progress-bar/reviews/)

## Tags

 * [load](https://wordpress.org/support/topic-tag/load/)

 * 3 replies
 * 2 participants
 * Last reply from: [Chris Reynolds](https://wordpress.org/support/users/jazzs3quence/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/loading-scripts-only-if-needed/#post-6637096)
 * Status: resolved