Title: Loading js after gallery appears
Last modified: August 22, 2016

---

# Loading js after gallery appears

 *  Resolved [Abacomancer](https://wordpress.org/support/users/abacomancer/)
 * (@abacomancer)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-after-gallery-appears/)
 * I am using a theme Zoo which loads a portfolio item only after you click on it.
 * That means that any galleries of yours I include in a portfolio item will never
   properly load. Specifically, my problem is that because the content isn’t loaded
   until that click, the js that is initially loaded doesn’t include the slideshow
   script. I was wondering if there is an easy solution to this problem. For instance,
   a hook I could call in the theme’s portfolio item template to recheck the js 
   that needs to be loaded.
 * Thank you
 * [https://wordpress.org/plugins/slideshow-gallery/](https://wordpress.org/plugins/slideshow-gallery/)

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

 *  Plugin Author [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * (@contrid)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-after-gallery-appears/#post-5565133)
 * [@abacomancer](https://wordpress.org/support/users/abacomancer/)
 * Thank you for your post.
 * Yes, the Slideshow Gallery uses `wp_head` and `wp_footer` functions in the theme
   to load it’s Javascript.
 * Since those functions of yours don’t yet know that there will be a slideshow,
   you can call them manually in the theme’s portfolio function after the HTML has
   been rendered. I’m not entirely sure how your theme does it but you can do some
   digging in it’s `functions.php` file and see if it’s there and then fire this
   code:
 *     ```
       $slideshow = new Gallery();
       $slideshow -> wp_head();
       $slideshow -> wp_footer();
       ```
   
 * Let me know if that works and helps.
 *  Thread Starter [Abacomancer](https://wordpress.org/support/users/abacomancer/)
 * (@abacomancer)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-after-gallery-appears/#post-5565295)
 * Thanks for the help. I tried the method you gave, and it mostly works.
 * I had to remove the line $slideshow -> wp_head();
    I assume this is because it
   contains files not allowed in the body. Unfortunately, since the portfolio items
   are inside of an existing page, I cannot give them their own head. To add this
   file, I would have to somehow trigger this call in the head when a portfolio 
   item opens.
 * However, most everything for the gallery works appropriately as is (or can be
   fixed via styling), so I do not believe I will have to pursue that. The one problem
   I was having as a result of this is with ‘.slideshow-slider’. The CSS as-is without
   the header files forces it to width 22px with a high specificity and !important.
   Instead of fighting it, I just went into the files and removed the !important.
 * If you have a better solution, I would be glad to hear it. Either way, I am very
   happy I could get this working. Thank you again for your help.
 *  Plugin Author [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * (@contrid)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-after-gallery-appears/#post-5565305)
 * [@abacomancer](https://wordpress.org/support/users/abacomancer/)
 * Actually, the code I gave you won’t create a header/footer.
 * When the HTML of the portfolio loads, the slideshow code will generate global
   Javascript code.
 * So when you fire `$slideshow -> wp_footer()` you simply echo that Javascript,
   nothing else.
 * That is the best solution I have at the moment.

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

The topic ‘Loading js after gallery appears’ is closed to new replies.

 * ![](https://ps.w.org/slideshow-gallery/assets/icon-256x256.png?rev=1187457)
 * [Slideshow Gallery LITE](https://wordpress.org/plugins/slideshow-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/slideshow-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/slideshow-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/slideshow-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/slideshow-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/slideshow-gallery/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/loading-js-after-gallery-appears/#post-5565305)
 * Status: resolved