You shouldn't try to load scripts dynamically after the page load without a very good reason, and this is true of any website you develop, not just Visualforce. Even so, you doubly shouldn't try to use expressions of any sort in a script that is rendered dynamically, because it can cause all sorts of unusual errors to crop up (and not just with remoting).
In fact, I would go so far as to say you should avoid trying to mix JavaScript and Visualforce at all for the best experience. While it's true that expressions are allowed within script blocks, they are generally fraught with pitfalls that would be avoided if one simply remoted exclusively; you no longer have to worry about proper escaping, order of re-render execution, or any other nonsense.
Interestingly, if you set the flag to true in the constructor, then click the "hide" button, and check your console, the function makeRemoteCall()
still exists. This means that there is at minimum a glitch with re-rendering scripts anyways. There may be some type of protection mechanism that the Visualforce library uses to avoid overwriting existing functions, or perhaps the function is rendered out of existence in the view state once it is hidden, thus causing the crash you've observed.
Either way, load your scripts when the DOM first loads. Do not try to be a hero by loading scripts at the last possible instant, because it is slower than just loading the resource immediately (you're not preventing the load time, only offsetting to a more noticeable point in the user experience). If you really want the function to be loaded "lazily", include it as a static resource using HTML5's "async" attribute; it will still be available by the time you need it. However, using that logic, you'll lose the ability to use expressions to bind to the function correctly.
Best Answer
This issue is not because of remote actions basically. Wherever we were calling remote actions using html tags in vf page, we were getting this error. We replaced html tags with apex tags (commandlink) and didn't change the remote actions. It works fine now. Html tags are not supported in lightning and error is bit misleading.