The solution and thinking of the problem that the content-download time of ajax is too slow

Second, look at the difference in calls to this component between business pages with latency issues and those without delays.

By comparison, there is no difference between the two components. (Therefore, interested students can contact me to discuss this mystery. I can send you the source code)

After reproducing the problem many times, it is obvious that in the chrome of the pc, the delay disappears occasionally when using touch mode, and the delay reappears when using mousewheel. Therefore, the problem is located in the mousewheel event and its close corresponding scroll event.

bug resolved:

Combining the reasons for the appeal and discussing through several posts reviewed, the following conclusions are drawn:

1. The mousewheel event of the chrome browser is the cause of this delay (the mousewheel event is not a standard event and is not recommended for everyone), of course! I didn't use the mousewheel event in the code, but using the scroll event may cause a conflict with the mousewheel event, and the webview in our special mobile client unfortunately also hit this flaw.

2. To solve this problem, you can try to listen for this event (if the browser does not have this event, it will not respond to this monitoring, there is no conflict), and when the event is triggered, cancel all its default behaviors:

Therefore, by listening to the deltaY (vertical scroll amount of the mouse) of its event model, when it has a vertical displacement, the preventDefault is triggered, so the code is as follows:

window.addEventListener("mousewheel", (e) => {
  if (e.deltaY === 1) {
    e.preventDefault();
  }
})

The essence of the compatibility issue:   

In the webkit architecture, some modules are generally not shared among browsers, and some modules are not shared with certain features in browsers, and their behavior can be changed through different compilation configurations. So, many browsers using webkit may behave differently.

The above is what Xiaobian introduced to you to solve the problem that the content-download time of Ajax is too slow. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply you in time. Thank you very much for your support to the Scripting House website! The solution and thinking of the problem that the content-download time of ajax is too slow

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325206508&siteId=291194637