ZF-5629: headScript()->appendScript() render twice when layout->setLayout

Description

when I used

$this->_helper->layout->setLayout('no_header_footer');

to change to another layout, and then I use

$this->headScript()->appendScript($script);

to append script, the $script render twice like

please check it out

Comments

A fix to prevent duplicate output.

The multiple rendering can be prevented by outputting the headSCript() call only once, e.g.: <?php echo $this->headScript()->appendFile('path/to/js1.js')->appendFile('path/to/js2.js'); ?>

And not: <?php echo $this->headScript()->appendFile('path/to/js1.js'); echo $this->headScript()->appendFile('path/to/js2.js'); ?>

This is not an issue, as noted in your comment, you are 'echoing' the view helper each time you are adding something. only echo the once, and this will not happen.