The invention discloses a method for obtaining webpage loading first
screen time delay, and belongs to the field of network and service testing. The method comprises the following steps of: firstly, obtaining and presetting the
layout of a target website; finishing downloading resources on a
html (
Hypertext Markup Language), injecting a js (
JavaScript) code at the beginning of the resource loading of the webpage of the target website while document.readState is already under an interactive state, carrying out
polling checking to calculate whether a
resource element loaded in a current webpage is loaded and displayed within a first screen range or not; and once first-screen resources conform to the
layout and finish being loaded, calculating the time
delay from time when a user requests a webpage to now, and recording as the first
screen time delay. Compared with the prior art, the method is simple in operation, the user only needs to click the function button to carry out a test without other complex operations, and
power consumption is low. The method only needs a simple script program to be operated, extremely low cpu and memory resources are occupied, other
power consumption hardware is not used, the user does not feel the execution of the method. The method has the advantages of being high in calculation speed, safe, reliable, high in universality, wide in applicability and easy in large-range popularization.