2

This question ( Weird browser / ajax error : Extra junk appears at the end of javascript files in firefox ) 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?

2 Answers 2

1

I hope if this work for you

Check browser’s cache for a js file

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.