Answer the question
In order to leave comments, you need to log in
Why does $(document).ready fire 6 times on Drupal8?
Curious moment. I replaced that $(document).ready fires several times, and when the blocks have not yet appeared, it also fires. This generates a lot of unnecessary operations and errors, because. many elements are still missing.
How can this be explained and how to fight?
Answer the question
In order to leave comments, you need to log in
1. $(document).ready fires only once after the DOM is formed, but there can be several handlers for this trigger. In your case, there are six.
2. If the blocks did not appear, but ready worked, then the blocks are added dynamically. Either through js or using AJAX. In this case, you need to build the correct order for loading js files and / or use callback functions to process the result of the request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question