有意减慢 HTML/PHP 页面加载以进行测试 [英] Intentionally Slow Down HTML/PHP Page Load to Test

查看:23
本文介绍了有意减慢 HTML/PHP 页面加载以进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇是否有一种方法可以故意减慢页面加载速度?

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

我正在测试我的 HTML &现在我本地主机上的 PHP 页面,我想看看当页面加载速度较慢时我的加载 gif 等将如何执行.

I'm testing my HTML & PHP pages on my local host right now, and I want to see how my loading gif etc will perform when the page load is slower.

我意识到这是一个罕见的请求,因为大多数开发人员只关心加速页面加载,但我认为可能有一种方法,使用 javascript/jQuery 或 PHP,来做类似的事情这是为了测试目的.

I realize this is a rare request as most developers are only concerned with speeding up page loads, but I thought there might be a method, using either javascript/jQuery or PHP, to do something like this for testing purposes.

感谢您的帮助!

注意:我正在 MAMP 上进行测试,因此这是在 Mac OS 10.7 上运行的 Apache 服务器

Note: I'm testing on MAMP, so that's Apache server running on Mac OS 10.7

推荐答案

你可以使用 php 的 sleep($seconds) 函数来减慢页面加载速度.但是,您需要将 隐式输出缓冲区刷新设置为on"ob_implicit_flush(true); 如果您希望在页面处理完成之前将任何内容发送到用户的浏览器.否则你的页面在加载完成之前不会有任何内容.单独调用 sleep 是行不通的.

You can use php's sleep($seconds) function to slow down a page load. However, you would need to turn implicit output buffer flushing to "on" with ob_implicit_flush(true); if you want anything to be sent to the user's browser before the page is done being processed. Otherwise your page won't have ANY contents until it's done loading. Calling sleep alone won't do the trick.

这篇关于有意减慢 HTML/PHP 页面加载以进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆