interstar
interstar

Reputation: 27206

Where do browsers store dynamically downloaded Javascript?

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?

Upvotes: 2

Views: 595

Answers (2)

Sterling Hirsh
Sterling Hirsh

Reputation: 111

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.

Upvotes: 0

Ahmed Atia
Ahmed Atia

Reputation: 17960

I hope if this work for you

Check browser’s cache for a js file

Upvotes: 1

Related Questions