Stop page onload Javascript

I have this chat tool on my website
Problem is that it pops up the chat box when people visit the site

I would like it minimized, so they click on it and enlarge but only if they need help

<script type="text/javascript">
    (function () {
        var options = {
            facebook: "265656", // Facebook page ID
            facebook_chat: true, // Facebook customer chat
            whatsapp: "444646", // WhatsApp number
            call_to_action: "Chat To Us", // Call to action
            button_color: "#932C8B", // Color of button
            position: "right", // Position may be 'right' or 'left'
            order: "facebook,whatsapp", // Order of buttons
        };
        var proto = document.location.protocol, host = "getbutton.io", url = proto + "//static." + host;
        var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = url + '/widget-send-button/js/init.js';
        s.onload = function () { WhWidgetSendButton.init(host, proto, options); };
        var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
    })();
</script>

I’m guessing its the onload function
How do I change it

well it appears it doesn’t support that feature out of the box. The problem here is that you are importing someone else’s code through the javascript and supplying it some options. You might be better off asking the getbutton.io people if there is a way to have it launch in minimized mode. There is nothing here that can set it as minimized.

Maybe they will have some undocumented option you can specify in that options object, but you would be better off asking them.

Failing an option to minimize exists as part of the api you might be able to wrap that functionality with your own button that destroy the chat and replaces it with a button to reinitialize when clicked. Other solutions could also be evaluated like adding a value to local storage to determine whether the chat is initialized or hidden when a user visits the site again.

Hey,

So this is great article that talks about faking that chat app until the user clicks on it. Benefit will be you are not loading any of that JS until the user needs it so will help speed the page up.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.