I use a technique that loads a js file when window is loading. Then compile the script and delete links after window finished loading. In this case, JavaScript would reside on a memory and you cannot be able to view it with page source view. I'm wondering that, if JavaScript takes effective as long as the page is still opened without significant performance drop? I notice on Chrome's dev tool that browser does garbage collection regularly. Does it wipe out my script in this case. Thank you.
I'm not quite sure what you're asking. Garbage collection won't wipe out your script, only parts of it that are unused (like if you use a variable once, etc).
Firefox with Firebug will show the source of your javascript even if it is dynamically loaded. It's normally true that you can not view source html generated by javascript. If the java script does everything on the fly, the source view would only show the code to load the javascript. Your description of what you are doing is a bit confusing. There are a number of frameworks that manipulate the browser DOM to display and use content. JQuery, AJAX being the most common ones. I guess the real question is - What are you trying to do? and why. Normal html/javascript development will do just about everything except large enterprise systems. Performance drop from what? Why worry about garbage collection?