Since I don’t know the internal execution strategy of the browser very well, this article can only vaguely guess some conclusions through some front-end tests:
1) Test examples
Made two examples:
1 -1) The script is executed directly in the page, and you can see the result by refreshing