PeSmith
PeSmith

Reputation: 271

Is "Page Source" BEFORE or AFTER JavaScript has been rendered?

In Firefox there is a menu item that displays "Page Source": View | Page Source (Ctrl+U). In Internet Explorer there is a similar function.

When you invoke it, it displays a nicely formatted and syntax-highlighted collection of HTML (and JavaScript) code.

What I don't know is whether this HTML (viewable in the Page Source) is the result of pre-processing of the JavaScript (resulting in modification of the original raw HTML) or just raw as received by HTTP GET.

Upvotes: 17

Views: 5314

Answers (4)

Greg
Greg

Reputation: 33650

It is the source that was returned to the browser by the server, before DOM updates made through javascript.

Upvotes: 3

mattsven
mattsven

Reputation: 23293

Unfortunately, it will always display the HTML as the page was before DOM-change by javascript, etc. So the answer is: what you are seeing is "raw as received by HTTP GET".

You can use a tool like Firebug (Firefox & Chrome) to see live dom changes. Or you can make your own function to display the live dom.

Upvotes: 3

Reid
Reid

Reputation: 19419

Before. The page source is the result of the GET request by the browser sans headers. If you want to view the updated content after scripts and so forth, you'll have to use a tool like Firebug or the Web Development toolbar.

Upvotes: 3

KatieK
KatieK

Reputation: 13853

The "View Source" code is the code before any JavaScript is applied.

Firefox's Web Dev toolbar will allow you to view the resulting post-JavaScript source code from the View Source > View Generated Source menu option.

Upvotes: 21

Related Questions