Delay script load
There may be times when you only want the Web chat to load for certain users, or on certain pages of your site. For this we offer the delayed load.
Use case: Support should only be offered to logged in customers, or customers of a particular plan / subscription type.
<script
defer
src="https://widget.mava.app"
widget-version="v2"
id="MavaWebChat"
data-token="YOUR_DATA_TOKEN"
delay-load="true" // This is the important line
></script>
Adding this to your script will ensure that the Mava web chat doesn't automatically run on page load. Instead you will need to dispatch a custom window event to trigger the script to run.
<button
onclick="
var newEvent = new Event('loadMavaWebchat');
window.dispatchEvent(newEvent);
">
Load Mava Script
</button>
You can trigger this event from any source in your code, e.g as a reaction to a fetch event where the users credentials are checked and verified. After this event has been dispatched you can then use Mava in the normal manner, either with our default Mava web chat icon launcher, or a custom launcher.
Last updated
Was this helpful?