(function() { var loaded = false; var queue = []; function runQueue() { loaded = true; queue.forEach(function(fn) { fn(); }); queue = []; window.dispatchEvent(new CustomEvent('gsapReady')); } window.gsapReady = function(callback) { if (loaded && typeof gsap !== 'undefined') { if (callback) callback(); return; } if (callback) queue.push(callback); }; function loadScript(src) { return new Promise(function(resolve, reject) { var s = document.createElement('script'); s.src = src; s.async = true; s.onload = resolve; s.onerror = reject; document.head.appendChild(s); }); } function doLoad() { if (loaded) return; var config = window.gsapLoaderConfig || {}; var base = config.cdn || 'https://cdn.jsdelivr.net/npm/gsap@3.12.5'; var splitTextUrl = config.splitTextUrl || ''; loadScript(base + '/dist/gsap.min.js') .then(function() { return loadScript(base + '/dist/ScrollTrigger.min.js'); }) .then(function() { if (typeof gsap !== 'undefined' && typeof ScrollTrigger !== 'undefined') { gsap.registerPlugin(ScrollTrigger); } if (splitTextUrl) { return loadScript(splitTextUrl).then(function() { if (typeof SplitText !== 'undefined') gsap.registerPlugin(SplitText); }); } }) .then(function() { runQueue(); }) .catch(function() { runQueue(); }); } function startLoad() { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { if (window.requestIdleCallback) { requestIdleCallback(doLoad, { timeout: 1500 }); } else { setTimeout(doLoad, 300); } }); } else { if (window.requestIdleCallback) { requestIdleCallback(doLoad, { timeout: 1500 }); } else { setTimeout(doLoad, 300); } } } var config2 = window.gsapLoaderConfig || {}; var triggerSelector = config2.triggerSelector || '[data-clock-section], [data-gsap-trigger], .middle_heading'; var useViewportTrigger = !!config2.loadOnViewport && !config2.firstScreen; var firstScreen = !!config2.firstScreen; if (firstScreen) { var preconnect = document.createElement('link'); preconnect.rel = 'preconnect'; preconnect.href = 'https://cdn.jsdelivr.net'; preconnect.crossOrigin = ''; document.head.appendChild(preconnect); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { requestAnimationFrame(function() { setTimeout(doLoad, 0); }); }); } else { requestAnimationFrame(function() { setTimeout(doLoad, 0); }); } } else if (useViewportTrigger) { var observer = new IntersectionObserver( function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { startLoad(); } }); }, { rootMargin: '150px', threshold: 0 } ); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { var el = document.querySelector(triggerSelector); if (el) observer.observe(el); else startLoad(); }); } else { var el = document.querySelector(triggerSelector); if (el) observer.observe(el); else startLoad(); } } else { startLoad(); } })();