fireship-io / flamethrower

A blazingly fast router for static sites
MIT License
2.78k stars 110 forks source link

Load array scripts synchronously #57

Closed nguyenhuylinhdev closed 2 years ago

nguyenhuylinhdev commented 2 years ago

Hi, this PR add function loadScriptSync to replace function replaceAndRunScript

Because when use replaceAndRunScript, script load not synchronous, so sometime it show error because other script not loaded

Screenshot_2

Screenshot_3

prowebat commented 2 years ago

I'm experiencing the same issue with the scripts. This pull request works, but the disadvantage is, that each script is loaded sequentially, which makes the page somewhat slower if you have many scripts.

Possible solutions I found:

nguyenhuylinhdev commented 2 years ago

Hi @prowebat, I found loadJS and and realize that just add async=false, it work like a charm! So I will close this PR and create new PR tomorrow.

Screenshot_2

Screenshot_1

prowebat commented 2 years ago

nice, that worked. and i also found out that you can just set it in the html with async="" (empty value)

hint for the new PR: "newScript.async = false" should be before line 113 (so attributes can overwrite the default false value).

nguyenhuylinhdev commented 2 years ago

Yeah, set async="" in html is worked but I have a problem:

link test source code

Screenshot_1

I will continue test it.