多少个div标签太多? [英] How many div tags are too much?

查看:112
本文介绍了多少个div标签太多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在影响性能之前,一个HTML文档中需要多少个div标签?在这种情况下,标签不是嵌套的,每个标签的内容都是最小的(背景颜色/图像)。



这个问题是对前一个问题的后续处理;
使用JavaScript绘制可点击的点线



在这里,我决定使用HTML和CSS来做这件事。 < div> / code>标签将具有至少4个像素的宽度,并且总宽度为400-800像素,从而具有100-200个div标签。

最重要的是,这些图表/时间表中将会有五个或六个堆叠在一起。然后,div标签的数量在500-1200之间。

同样,由于每个标签的内容很少,这会如何影响性能?



_L

解决方案

虽然标记计数在渲染html时肯定会产生影响,以基准来查看时间是否可接受。

在那里我会担心的是您可能试图遍历DOM的JavaScript函数。纵观所有这些因素,对客户而言可能是一项代价高昂的操作。虽然再一次,适当的基准不能被替代。


How many div tags in one HTML document would one need before it affects performance? In this case, the tags are not nested and the content within each is minimal (background color/image).

This question is a follow-up on a previous question; Drawing lines with clickable points using JavaScript

Here I settled on doing this using HTML and CSS.

The <div> tags will have a width of at least 4 pixels, and a total width of 400-800 pixels, thereby 100-200 div tags.

On top of that, there will be five or six of these graphs/timelines stacked on top of each other. The number of div tags is then up in 500-1200.

Again, bearing that there is little content in each, how would this affect the performance?

_L

解决方案

While tag count surely has an impact when rendering html you will have to benchmark to see whether or not the time is acceptable or not.

Where I would be concerned is javascript functions that you may have that try to traverse the DOM. Looking through all those elements could be a costly operation on the client. Though once again, proper benchmarking can not be substituted.

这篇关于多少个div标签太多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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