Show loading splash screen until hs chat is visible

SOLVE
jakobtiebel
Member

Hi folks,

 

I want to embed hs-chat on a single page for support reason. So far so good: https://docbox.ch/chat.html

 

But due to documented performance issues the chat window needs up to 5 sec until its visible (loaded).

 

Is it possible to show a loading splash screen until the chat window is visible?

 

I tried to use

$(window).load(function() {});

 as indicator for the loading but it does not detect the chat.

 

Please advise.

 

0 Upvotes
1 Accepted solution

Accepted Solutions
Kevin-C
Solution
Recognized Expert

Thanks @dennisedson 

This is a fun one!

 

Hey @jakobtiebel 

 

You can check against window.hubspot_live_messages_running using a recursive function:

 

function doStuff() {
  if(!window.hubspot_live_messages_running) {// Check if it's true
    console.log('not yet');
    setTimeout(doStuff, 50);//Wait 50 millisecnds then recheck
    return;
  }
  console.log("It's ready!");//Do stuff
}
doStuff();

 

 I think there might event be an event you can listen for but I haven't had time to dig through the docs

View solution in original post

3 Replies 3
dennisedson
Community Manager

@Kevin-C , any advice?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
jonchim
Guide | Diamond Partner

Hey @jakobtiebel,

Can you give this a shot and see if that works? you may just need to set a longer delay on your splash screen

$(window).on('load', function()

 






Jon Chim
Design Director
Morey Creative Studios


check Did my post help answer your query? Help the Community by marking it as a solution
Kevin-C
Solution
Recognized Expert

Thanks @dennisedson 

This is a fun one!

 

Hey @jakobtiebel 

 

You can check against window.hubspot_live_messages_running using a recursive function:

 

function doStuff() {
  if(!window.hubspot_live_messages_running) {// Check if it's true
    console.log('not yet');
    setTimeout(doStuff, 50);//Wait 50 millisecnds then recheck
    return;
  }
  console.log("It's ready!");//Do stuff
}
doStuff();

 

 I think there might event be an event you can listen for but I haven't had time to dig through the docs

View solution in original post