简体   繁体   中英

How to handle user interactions when javascript sources are still downloading?

Putting all the JavaScript resources before the closing tag of body in an HTML page is suggested so that user can see the some part of the UI loaded. But what if user interacts with elements that handles some actions that is handled in one of the JavaScript source file that is not yet loaded?

Example: Consider there is an HTML page loded from the server. It tries to load 4 resources: 1. Css file 2 images data 3. And Jquery sources 4. Javascript source file to handle the user interactions

When user clicks the button, even before the JavaScript (4th source) is loaded...how to handle the problem?

您不能..如果您在加载时间上重视可靠性,则可以将脚本标签放在头部..或者您可以只使用加载器..(有些div会覆盖整个屏幕,直到页面加载完成)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM