最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

PHP, HTML, Javascript execution order - Stack Overflow

matteradmin12PV0评论

I have a test.php file and this file contains some PHP code, HTML elements and some internal JavaScript and some external JavaScript include.

I want to know which is first to load or execute.

PHP or HTML or JavaScript? I want to know execution order.

Your answers are greatly appreciated and very helpful to me and others also.

I have a test.php file and this file contains some PHP code, HTML elements and some internal JavaScript and some external JavaScript include.

I want to know which is first to load or execute.

PHP or HTML or JavaScript? I want to know execution order.

Your answers are greatly appreciated and very helpful to me and others also.

Share Improve this question edited Jun 8, 2016 at 11:49 GottZ 4,9471 gold badge37 silver badges47 bronze badges asked Jun 4, 2012 at 6:55 prakashprakash 1842 silver badges10 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 16

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.

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far