How to prevent execution of Javascript in the event of multistep Webfom ajax page transition?

Hi

I have a problem with multipage Webform in which all previously loaded scripts are executed when page is changed.

For example on the first page of my form there’s functionality that relies on custom javascript.
This should only be executed on that “page” (page that has that field).
And now, when I’m trying to change the page it executes this script and causes an error since “bind function is undefined” or similar (and AJAX overlay stays on page).

It seems to me that previosly loaded scripts are executed but on the new DOM (AJAX returned form markup) and in different order than on the first page load.
How could I prevent this from happening? Same goes for previous page that it is executing

Is it possible to hook and alter ajax_pagestate settings/variable? And can it be used for managing javascripts that are loaded etc?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed