Title: Only load scripts weh needed
Last modified: August 30, 2016

---

# Only load scripts weh needed

 *  Resolved [JasperPress](https://wordpress.org/support/users/jasperpress/)
 * (@jasperpress)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/only-load-scripts-weh-needed/)
 * I was wondering if it is possible to only load the plugin scripts when the Instagram
   Feed is inserted on the page.
    The way it works now is that the scripts and stylesheets
   are loaded on all pages and posts, even if there is no instance of the IG feed
   present. This means extra loading time that can be avoided.
 * Is there a way to prevent the scripts/stylesheets from loading when they are 
   not needed?
 * [https://wordpress.org/plugins/instagram-feed/](https://wordpress.org/plugins/instagram-feed/)

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

 *  Plugin Author [smashballoon](https://wordpress.org/support/users/smashballoon/)
 * (@smashballoon)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/only-load-scripts-weh-needed/#post-6688793)
 * Hey Jasper,
 * As the plugin uses a shortcode to load the feed then it’s difficult to do this,
   as when loading the header of your site it doesn’t know yet whether the [instagram-
   feed] shortcode is going to be in the content of that page. The good news is 
   that as web browsers cache CSS and JavaScript files then there isn’t any additional
   requests or loading time when the visitor goes from page to page.
 * If you really wanted to only load the plugin files on certain pages then you 
   could dequeue the plugin CSS and JavaScript files in your theme’s functions.php
   file and then add a conditional in your header and footer file which only includes
   them on certain pages. Let me know whether that makes sense.
 * John
 *  Thread Starter [JasperPress](https://wordpress.org/support/users/jasperpress/)
 * (@jasperpress)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/only-load-scripts-weh-needed/#post-6688799)
 * Hi John,
 * Thanks for the speedy response.
    I totally get what you’re saying and you have
   a good point. Since the feed is shown on the homepage the script is already cached
   by most of the visitors and it would seem to much of a hassle to dequeue it and
   conditionally add it again.
 * Cheers!
    Jasper
 *  Plugin Author [smashballoon](https://wordpress.org/support/users/smashballoon/)
 * (@smashballoon)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/only-load-scripts-weh-needed/#post-6688817)
 * No problem, just let me know if you have any other questions at all and I’d be
   happy to help!
 * Also, no obligation of course, but if you like the plugin and feel like leaving
   a super-quick [review](https://wordpress.org/support/view/plugin-reviews/instagram-feed)
   then we always really appreciate it 🙂
 * John

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

The topic ‘Only load scripts weh needed’ is closed to new replies.

 * ![](https://ps.w.org/instagram-feed/assets/icon-256x256.png?rev=2700807)
 * [Smash Balloon Social Photo Feed – Easy Social Feeds Plugin](https://wordpress.org/plugins/instagram-feed/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/instagram-feed/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/instagram-feed/)
 * [Active Topics](https://wordpress.org/support/plugin/instagram-feed/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/instagram-feed/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/instagram-feed/reviews/)

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [smashballoon](https://wordpress.org/support/users/smashballoon/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/only-load-scripts-weh-needed/#post-6688817)
 * Status: resolved