简体   繁体   English

HTML5 网站上的性能问题

[英]Performance Issue on an HTML5 Website

I am building an Webpage that uses SVG, Canvas and, of course, HTML.我正在构建一个使用 SVG、Canvas 的网页,当然还有 HTML。 The idea of this page is to animate the redrawing of some of svg-paths on the canvas.这个页面的想法是动画重绘 canvas 上的一些 svg 路径。 The paths I like to redraw are annotated with an namespace Attribute, all other paths are just displayed as they are.我喜欢重绘的路径使用命名空间属性进行注释,所有其他路径都按原样显示。 That is all working fine.这一切都很好。 The performance leak appeared the last two hours while I was adding some content to the page: But at first a little illustration of the page setup:在我向页面添加一些内容时,最近两个小时出现了性能泄漏:但首先是页面设置的一个小插图:页面设置说明

The SVG and the Canvas are both 4000 * 4000 px wide and lie directly over each other in one container div. SVG 和 Canvas 都是 4000 * 4000 px 宽,并且在一个容器 div 中直接相互重叠。 Going from one "page" to another means to tween the upper left edge of this container.从一个“页面”到另一个意味着补间这个容器的左上边缘。 This was also working fine since the discussion of inserting text turned in the direction of using html div container, instead of the svg itself.这也很好,因为关于插入文本的讨论转向使用 html div 容器,而不是 svg 本身。 So i inserted a third container div in which all the texts are stored and after svg is loaded they are positioned absolutly.因此,我插入了第三个容器 div,其中存储了所有文本,并且在加载 svg 后,它们绝对定位。 With every div I added the "pan-tween" and even the drawing performance decreased to a Point that is just too low.对于每个 div,我都添加了“泛补间”,甚至绘图性能也下降到了一个太低的点。 I am searching for way to bring the performance back to a level that is acceptable for the user.我正在寻找将性能恢复到用户可以接受的水平的方法。 One of my ideas is to set text divs to display: none, or visibility: hidden, as long as they are not displayed actually.我的想法之一是将文本 div 设置为 display: none 或 visibility: hidden,只要它们实际上没有显示。 Another option is to tween only svg and canvas, after this is finished placing the text-div-container in one step.另一种选择是仅对 svg 和 canvas 进行补间,然后一步完成放置 text-div-container。 But I am currently not sure which solution is better, or if there isn't something much better.但我目前不确定哪种解决方案更好,或者是否没有更好的解决方案。 So if anybody has an Idea, please let me know.所以如果有人有想法,请告诉我。

Thanks for reading!谢谢阅读! Greetings Philipp问候菲利普

Try to pan the outer "text div" in intervals(say 10ms or 50ms).尝试以间隔(比如 10 毫秒或 50 毫秒)平移外部“文本 div”。 I this with a lot with rendering, in HTML usually I use greater values like 100ms or 150ms(I use to do this with canvas).我用很多渲染,在 HTML 通常我使用更大的值,比如 100 毫秒或 150 毫秒(我用画布来做这个)。 Didn't understand if you pan the outer div or all the "text divs".不明白您是平移外部 div 还是所有“文本 div”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM