Articles on: Developers

How to programmatically hide and show the live chat widget

Use JavaScript to choose when visitors can see the Crisp live chat widget as they move through your site.


Your application can react to a change of page, account state, or activity by hiding or showing chat. For fixed rules such as hiding chat on every checkout page, you can configure page visibility in Crisp.



Control chatbox visibility


Place the calls below after your Crisp installation snippet has initialized window.$crisp. The JavaScript SDK queues these actions while the widget script loads.


Hide the chatbox


Call chat:hide when the visitor reaches a part of your site where chat should be hidden.


$crisp.push(["do", "chat:hide"]);


This hides both the chat button and any open chatbox. Crisp continues running and processing data on the page, and keeps the current session. If your condition determines whether Crisp should load at all, see conditional loading with Google Tag Manager.


Show the chatbox again


Call chat:show when the visitor returns to a part of your site where chat should be available.


$crisp.push(["do", "chat:show"]);


The chatbox keeps its open or closed state while hidden. If it was closed, showing it brings back the button. If it was open, showing it brings back the open chatbox.


To reveal and open chat from your interface, call chat:show followed by chat:open. The custom chat button guide combines those calls in a complete example.


Apply visibility when the page changes


Apply your condition each time a page loads. In a single-page app, also run it when the route or relevant application state changes. Include both the hide and show cases so a visitor returning to a page that offers support can find chat again.


Test both transitions with the chatbox closed, then with it open. Check that hiding removes the widget and showing it restores its previous state.


Example → An app could hide chat while a customer completes a full-screen task, then show it again when they finish.


The $crisp method reference also covers closing an open chatbox with chat:close or switching between open and closed with chat:toggle.

Updated on: 02/12/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!