SoFunction
Updated on 2025-03-10

Strange problems encountered when using web pages

During the research on the porting of Razor template engine to JavaScript a few days ago, I found that if the output content contains the <script> tag that calls external JavaScript, a little problem may occur - the external JavaScript called here may be executed at an inappropriate time. For IE and Opera, these external JavaScript will be executed only after all other parts of the write parameters are parsed.

In further research, I found that for Chrome and Safari, two browsers that use the WebKit web layout engine, if the externally called JavaScript is called again and write another <script> tag that calls external JavaScript, the second call to the external JavaScript will not be executed, and some subsequent content will be disrupted - the actual situation is actually a little more complicated, and it is related to the specific content in the parameters of the second and third levels of call, because of the relationship between time and energy, I cannot do more specific tests.

After these research, the only surviving of the major mainstream browsers that can handle all calls correctly is Firefox.
Firefox's pseudo-"multi-threaded" event processing feature has always been something I don't like, and this matter can be regarded as a proof of "everyone has its own strengths".

If you want to understand the various phenomena caused by this problem, you can download it, decompress it and open it in various browsers.

I have been trying to write a replacement function to solve this problem these days, and I have been able to successfully pass the test in the above link.
If no obvious problem is found in the next few days, I will post it on the blog for your reference.
Test code, package download