Behaviors will be executed on every request, including AJAX requests.
you can use the once function to make sure it is only triggered once.
(function ($, Drupal) {
Drupal.behaviors.mei_library_turn = {
attach: function(context, settings) {
$('main', context).once('mei_library_turn', ).each(function () {
console.log('ready1');
};)
// There would be a lot more code in here, but I've stripped it all out to debug.
}
};
})(jQuery, Drupal, drupalSettings);