Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have a test.php file and this file contain some php code,html element and some internal javascript and some external javascript include

i want to know which is first load or execute.

php or html or javascript ? i want to know execution order

your answers are great appreciated and vary helpful to me and others also

share|improve this question
Please accept an answer by clicking the checkmark next to it, thanks! – Jack Jun 11 '12 at 15:10

2 Answers

up vote 3 down vote accepted

Pragmatically speaking, this is the typical order:

  • PHP runs first and constructs the page.
  • The browser loads the resulting HTML (any JavaScript found gets executed immediately)
  • Any JavaScript that was tied to the DOM ready or load event gets executed once the whole HTML is read and all objects are loaded respectively.
share|improve this answer

PHP will execute first, then HTML and finally javascript.

  • You send request to server, server executes your script
  • Then returns rendered html to browser, browser parses HTML(inline javascript executed)
  • Finally executes external included javascript files, one by one in order they are included.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.