Following the story Chat-widget API sneak peek + small tutorial , we might explained it wrong, the way you use the API , or better said , based on the examples we didn’t show you the fastest way of using the API.
Let me explain what we’re talking about. We said in that post:
And this is true, but our examples were based on the second situation, and none of the first , which in this case is faster(not super fast, but a little faster).
So.. Instead of waiting for the entire page to load (using window.onload) before initializing your code, you can do it just after you embedded the widget like in this example:
Notice that we removed the window.onload event, but we declared the api after the embedded code was inserted to your page.
If you want to use the window.onload event or <body onload=”//do something”> it doesn’t matter where you put the code, because it will be implemented only after the entire page is loaded.
Hope this helps improve your code and make it as clean as possible.
Have fun coding