- A+
若您的网站主题支持自定义JavaScript代码添加,把下面的JS代码复制粘贴到里面即可。如果不支持,在网站根目录下新建文件fps.js
新建文件粘贴以下代码
<script type="text/javascript">
// <a href="http://img.8gws.com/article/tag/fps%e5%b8%a7%e7%8e%87/" title="查看与 FPS帧率 相关的文章" target="_blank">FPS帧率</a>代码
$('body').before('</p>
<div id="fps" style="z-index:10000;position:fixed;background-image: linear-gradient( 120deg, #f093fb 0%, #f5576c 100%);-webkit-background-clip: text;color: transparent;"></div>
<p>');
var showFPS = (function(){
var requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000/60);
};
var e,pe,pid,fps,last,offset,step,appendFps; </p>
<p> fps = 0;
last = Date.now();
step = function(){
offset = Date.now() - last;
fps += 1;
if( offset >= 1000 ){
last += offset;
appendFps(fps);
fps = 0;
}
requestAnimationFrame( step );
};
appendFps = function(fps){
console.log(fps+'FPS');
$('#fps').html('FPS:'+fps);
};
step();
})();
</script>
调用方法:进入WordPress后台-主题设置-插入代码-页脚代码,粘贴如下代码保存:<script charset="UTF-8" src="/fps.js"></script>
- 我的微信公众号
- 扫一扫关注
- 我的新浪微博号
- 扫一扫关注