Intentionally Slow Down HTML/PHP Page Load to Test

前端 未结 8 1414
别跟我提以往
别跟我提以往 2020-12-08 04:32

I\'m curious if there exists a method to intentionally slow the page load?

I\'m testing my HTML & PHP pages on my local host right now, and I want to see how my

8条回答
  •  旧时难觅i
    2020-12-08 04:42

    This is what I would try: Use a php resource as source of the image:

    
    

    in gifLoader.php, read your image file, output it byte by byte with a delay in the loop.

    $fp = fopen( $path, 'rb');
    while(!feof($fp)) {
            print(fread($fp, 1024));
            flush();
            Sleep(1);
         }
    fclose($fp);
    

    Don't forget to appropriately set the headers before outputting the binary data.

    Referrences:

    http://stackoverflow.com/questions/1563069/stream-binary-file-from-mysql-to-download-with-php
    http://php.net/manual/en/function.sleep.php
    http://www.gamedev.net/topic/427622-php-and-file-streaming-script-with-resume-capability/
    

    UPDATE 2015-04-09 Use Chrome 'Device Mode': This tool has a network throttling feature that allows you to see how your page may render on a device with a slow network bandwidth. It has many other features that allow you to emulate features on various devices such as screen size and touch.

    https://developer.chrome.com/devtools/docs/device-mode

提交回复
热议问题