Title: Specific Events to trigger Lightbox Scripts?
Last modified: April 21, 2023

---

# Specific Events to trigger Lightbox Scripts?

 *  Resolved [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [3 years ago](https://wordpress.org/support/topic/specific-events-to-trigger-lightbox-scripts/)
 * I am looking for a tutorial on how to use FlyingScripts for scripts like Lightboxes
   or Slideshows. They are working fine for me but as soon as i load them through
   FlyingScripts, i get console errors like “Uncaught ReferenceError: Splide is 
   not defined”. Therefore i wonder how to rewrite the code.
 * Is there a specific event like “DOMContentLoaded” to handle that?

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

 *  Plugin Author [Gijo Varghese](https://wordpress.org/support/users/gijo/)
 * (@gijo)
 * [3 years ago](https://wordpress.org/support/topic/specific-events-to-trigger-lightbox-scripts/#post-16677189)
 * [@nicmare](https://wordpress.org/support/users/nicmare/) you’ve delay all JS 
   files and inline scripts related to the Splide.
 *  Thread Starter [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [3 years ago](https://wordpress.org/support/topic/specific-events-to-trigger-lightbox-scripts/#post-16677318)
 * Yes exactly but do you provide a sample snippet or documentation how to do this?
   With setTimeout function ?
 *  Thread Starter [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [3 years ago](https://wordpress.org/support/topic/specific-events-to-trigger-lightbox-scripts/#post-16680961)
 * after analyzing your code which simply uses a settimeout function, i simply use
   that as well in my custom script with 100ms delay. If someone else is looking
   for this, simply wrap your code (which is lazy loaded by flyingscript) like this:
 * `setTimeout(function(){
   let lg_gallery = _document_.querySelector('#hero');if(
   _document_.querySelector('.splide')){var splide_single = new Splide( '.splide',{
   type : 'slide',perPage: 1,lazyLoad: "nearby",pagination: false,focusableNodes:'
   a, button, textarea, input, select, iframe, span, img'} );}},100);
 * this is an example code with splidejs.

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

The topic ‘Specific Events to trigger Lightbox Scripts?’ is closed to new replies.

 * ![](https://ps.w.org/flying-scripts/assets/icon-256x256.png?rev=2240444)
 * [Flying Scripts: Delay JavaScript to Improve Site Speed & Performance](https://wordpress.org/plugins/flying-scripts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/flying-scripts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/flying-scripts/)
 * [Active Topics](https://wordpress.org/support/plugin/flying-scripts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/flying-scripts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/flying-scripts/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [nicmare](https://wordpress.org/support/users/nicmare/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/specific-events-to-trigger-lightbox-scripts/#post-16680961)
 * Status: resolved