I am using ZF2 and facing a weird behavior. When I use the headScript to append or prepend some Javascript file, the file is included twice. The same happens with inlineScript.
This is my actual view with the headScript()->appendFile():
<?php echo $this->headScript()->appendFile($this->basePath('js/dashboard.min.js')); ?>
With this implementation, when my page is loaded, all the requests are made twice and this is very bad cause are async requests to an API:
Test
[2, 1, 0, 0, 0, 0, 0]
Test
[2, 1, 0, 0, 0, 0, 0]
I tried also without the $this->basePath()
:
<?php echo $this->headScript()->appendFile('js/dashboard.min.js'); ?>
And got the same behavior.
But if I put this Javascript without the headScript, it just works fine, include once.
<script src="js/dashboard.min.js"></script>
// And the output
Test
[2, 1, 0, 0, 0, 0, 0]
What I can see is that the first include is made when page is loaded and the second some seconds after (2 or 3 seconds).
Someone already faced this behavior? If yes, Did Solve it? How?