I want to load the needed js files only when a page really is loaded.
Because i am using barba js it is not that easy with refreshing the scripts.
For that reason @pixelijn helped me to get the blocks from the used page.
<script> var slider; </script> <?php if ($doesBlockXExist->isNotEmpty()) : ?> True <script> slider = true; </script> <?php else : ?> False <script> slider = false; </script> <?php endif ?> <script> console.log(slider); </script>
True and false are echoed correctly on the website, but the console.log always logs the first state.