That one won't be as it's not a fix.
Using "<!--\n".$js."\n//-->" is not a problem and in fact the recommended way of adding javascript in joomla in order to have a HTML valid page. If we had that last modification, it wouldn't be HTML valid and we would have complains about that.
Also, that works for everyone else. There is really something on your website messing with the javascript somewhere.
So make sure that you back up these two files on even better, that you redo these changes in the new version of these files if you still have the problem when you update.
The cart.php file should change much in the future. However, the other one will.