I have PHP which gives minified JS as output through
That's what you are doing wrong.
Don't do any output through heredoc - it makes absolutely no sense in PHP. Just close PHP tag and write whatever JS as is.
?>
function prerefresh(){$("#len").empty();predata.forEach(item)}
it's the most natural way.