LELB Society - A bilingual Academy of English and Persian or Farsi

LELB Society: An Online Learning Community for Lifelong Learners

Join a global community of learners exploring English, Persian, technology, communication, AI, and other practical skills. Study thousands of video-based lessons, participate in asynchronous and live courses, complete hands-on projects, and receive continuous teacher support through discussions, comments, and interactive learning.

Modern Web Series

Modern Web Series explores practical tips, ideas, tools, and techniques for building, managing, and improving modern websites. From WordPress and web performance to useful code snippets and digital strategies, each episode focuses on a practical topic you can apply to your own website. Follow us on social media to watch the episodes and explore the archived episodes released so far.

Follow LELB Society for New Lessons, Posts and Articles

Episode 20: Lazy Loading Live Chats

<script>
(function () {
    let chatLoaded = false;

    function loadLiveChat() {
        if (chatLoaded) return;
        chatLoaded = true;

        const script = document.createElement('script');

        // Replace this with your actual live chat JavaScript URL
        script.src = 'YOUR LIVE CHAT JS';
        script.async = true;

        document.body.appendChild(script);

        // Remove the event listeners after loading
        window.removeEventListener('mousemove', loadLiveChat);
        window.removeEventListener('scroll', loadLiveChat);
        window.removeEventListener('touchstart', loadLiveChat);
        window.removeEventListener('keydown', loadLiveChat);
    }

    // Load the live chat after the visitor interacts with the page
    window.addEventListener('mousemove', loadLiveChat, { once: true });
    window.addEventListener('scroll', loadLiveChat, { once: true });
    window.addEventListener('touchstart', loadLiveChat, { once: true });
    window.addEventListener('keydown', loadLiveChat, { once: true });
})();
</script>