Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "Source" and "Generated Source"?

What is the difference between "Source" and "Generated Source" in Firefox?

Please explain with example.


Edit: 3 July

Which source "Search engine" uses, Generated or before generated?

like image 342
Jitendra Vyas Avatar asked Jul 02 '10 05:07

Jitendra Vyas


3 Answers

View source will show the source that was served by the server.

View generated source will show the source code of what's actually being shown — that includes what JavaScript has changed, etc.

like image 20
icktoofay Avatar answered Nov 19 '22 16:11

icktoofay


Source will show the source that the page was loaded with (served by the server).

Generated source will draw 'source code' from the current DOM elements, and therefore includes elements dynamically created by JavaScript.

For example, source would show:

<script>
  window.onload = function(){
    document.getElementById('test').innerHTML = 'Generated Content';
  }
</script>
<html>
  <div id='test'>Source</div>
</html>

and Generated Source would 'draw' the source at the time you click 'View Generated Source', after which the div's contents have been changed, and you would see:

<script>
  window.onload = function(){
    document.getElementById('test').innerHTML = 'Generated Content';
  }
</script>
<html>
  <div id='test'>Generated Content</div> <!-- Note the difference here -->
</html>
like image 131
Jon Weers Avatar answered Nov 19 '22 15:11

Jon Weers


It's really pretty simple.

Source:

<body>
    <script>document.write("hello, world");</script>
</body>

Generated source:

<body>
    <script>document.write("hello, world");</script>
    hello, world
</body>

More verbosely: "source" is what arrives at the browser in response to the page request. "Generated source" is what the browser has after all the javascript fires.

like image 5
egrunin Avatar answered Nov 19 '22 15:11

egrunin