During the previous research on porting the Razor template engine to JavaScript, I found that if you use document. the write output contains the <script> flag that calls external JavaScript, which may cause a problem. The called external JavaScript may be executed at an inappropriate time, for IE and Opera, the external JavaScript will be executed only after all the other parts of the write parameter are parsed.
In further research, I found that for Chrome and Safari browsers that use the WebKit web page typographical engine, if the externally called JavaScript calls document again. write to write the <script> flag of another external JavaScript call, the external JavaScript called for the second time will not be executed, some subsequent content will also be disrupted-the actual situation is actually a little more complicated, with level 2 and level 3 document. the specific content of the write call parameter is related, because the time and energy are related, I cannot perform more specific tests.
After these studies, the only major browsers that survive and can correctly handle all document. write calls will be Firefox.
The processing feature of a pseudo "multi-thread" event in Firefox has always been something that I don't want to wait for. It is also an evidence of "each has its own strengths.
.
Over the past few days, I have been trying to write a replacement function to solve this problem. Now I can successfully pass the test in the link above.
If no obvious problem is found in the next few days, I will post it on my blog for your reference.
Test code, package and download