JxBrowser provides functionality that you can use to detect when the loaded web page becomes unresponsive (e.g. because JavaScript execution on the web page take more than 30 seconds). When the web page becomes unresponsive you can display alert message to the end user to inform them about the situation and suggest to wait or kill the Browser instance. Also, you can get notifications when web page becomes responsive again.

The following example code demonstrates how to register RenderListener for getting these notifications:

Browser browser = new Browser();
browser.addRenderListener(new RenderAdapter() {
    public void onRenderUnresponsive(RenderEvent event) {
        // Web page is unresponsive :(

    public void onRenderResponsive(RenderEvent event) {
        // Web page is responsive again :)

To kill the Browser instance when web page becomes unresponsive you can use the Browser.dispose() method.

Note: Chromium doesn't fire the onRenderUnresponsive event if there was no user activity (mouse or keyboard events) on the unresponsive web page. There's an internal timer in Chromium functionality that watches user activity and decide whether the onRenderUnresponsive event should be fired or not depending on the unresponsive state since last mouse or keyboard event sent to the web page. If you freeze the web page, but no mouse or keyboard events are sent to the web page since that freeze, Chromium will not send the onRenderUnresponsive event.