views:

79

answers:

2

This question ( http://stackoverflow.com/questions/1199467/weird-browser-ajax-error-extra-junk-appears-at-the-end-of-javascript-files-in ) set me thinking ... I know what happens when I dynamically update the DOM on a web, page. At least, there's a tree of nodes representing the document and I can modify it.

But where does a browser put Javascript? How does a library like YUI dynamically load extra code?

+1  A: 

I hope if this work for you

Check browser’s cache for a js file

Ahmed
Thanks. That was interesting, but not quite what I was asking about. I was thinking more of the dynamic loading under the control of the program. An answer to my previous question made it sound as though YUI was dynamically adding code to an in-memory copy of a js file and it was the organization of code in the browser's memory I was curious about.
interstar
A: 

Once the code is in a variable in javascript, it can be eval'd from right there. You call eval on a variable with a string containing code in it and javascript executes that code.

<script>
var x = "alert('hi')";
eval(x);
</script>

So when the javascript is fetched with ajax or something, it can be eval'd from there, but it would never have to be injected into the DOM.

Sterling Hirsh