CSS 性能分析器?

发布于 2024-10-20 03:54:22 字数 195 浏览 5 评论 0 原文

我目前正在开发一个网站,在我的大量样式表中,有一些东西正在影响 IE 的性能。有没有好的 CSS 分析器?我想要一个可以查明影响性能的规则的工具。

在你问之前,我已经禁用了 JavaScript、不透明度和框阴影/文本阴影规则。页面仍然跳动。 :/ 如果我禁用所有 CSS,它运行得很好。

我需要一个可以分析页面并报告 CSS 瓶颈所在的工具。

I'm currently working on a site, and somewhere in my mass of stylesheets, something is killing performance in IE. Are there any good CSS profilers out there? I'd like a tool that can pinpoint rules that are killing performance.

Before you ask, I've disabled JavaScript, opacity, and box-shadow/text-shadow rules. The page is still jumpy. :/ If I disable all CSS, it runs great.

I need a tool that can profile the page and report where the CSS bottlenecks are.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

后知后觉 2024-10-27 03:54:22

因此,我终于开始编写一个 JavaScript 函数,该函数对页面上的所有 CSS 类进行索引,然后在滚动页面时单独切换它们。这立即查明了错误的类,从那里,我能够确定错误的属性。事实证明,包含许多子元素(例如主体级别 div)的 border-radius 执行效果令人难以置信 IE9 表现不佳。

我已经为 CSS 压力测试创建了一个 github 存储库: https://github.com/andyedinborough/stress- 从那里,您可以安装一个书签

以轻松地在任何页面上运行测试。

So, I finally got around to writing a JavaScript function that indexed all of my CSS classes on the page and then individually toggled them, while scrolling the page. This immediately pin-pointed the errant class, and from there, I was able to determine errant property. Turns out that border-radius on an element that contains many children (e.g. a body level div) performs incredibly poorly on IE9.

I've started a github repo for my CSS stress test: https://github.com/andyedinborough/stress-css

From there, you can install a bookmarklet to easily run the test on any page.

淡淡绿茶香 2024-10-27 03:54:22

Google 的 Page Speed 插件有一个部分可以分析您的 CSS 并告诉您效率低下的情况选择器,也许从那里开始?

hth

注意:我知道它是一个 Firefox 插件,但应该有助于优化一点:)

The Page Speed plugin from Google has a section that analyses your CSS and tells you about inefficient selectors, perhaps start there?

hth

Note: I know its a Firefox plugin, but should help optimize a bit :)

风向决定发型 2024-10-27 03:54:22

嗯,从来没有听说过这样的工具。

如果您找不到任何内容,则需要手动注意的事项将包括

  • 任何filter语句(经典的alpha=opacity和其他 - IE有许多非常先进的图形化非常昂贵的过滤器)

  • 巨大的元素(例如数千像素大)

  • 巨大的背景图像 - 也许将它们全部删除一会儿?

我强烈怀疑第一点 - Alpha 透明度可能是一个可怕的渲染瓶颈,尤其是在较旧的系统上。

Hmm, never heard of such a tool.

If you find none, things to look out for manually will include

  • Any filter statements (the classic alpha=opacity and others - IE has a number of very advanced graphical filters that are extremely expensive)

  • Huge elements (like thousands of pixels large)

  • Huge background images - maybe remove them all for a moment?

I would strongly suspect the first point - alpha transparencies can be a terrible rendering bottleneck, especially on older systems.

雾里花 2024-10-27 03:54:22

我目前正在开发的一个网络项目也遇到了性能问题。它在 Firefox、Chrome、甚至 IE8 中运行良好。在 IE9 中它陷入困境。

经过一些侦探工作,我发现消除所有 box-shadow CSS 行可以显着提高性能。我有来自横幅、表格、框和选项卡的阴影,每一个都只有少量的阴影和模糊,但显然足以让 IE9 变得情绪化。

I also have performance problems on a web project I'm currently working on. It runs well in Firefox, Chrome, even IE8. In IE9 it bogs down.

After some detective work I discovered that eliminating all box-shadow CSS lines improved performance considerably. I had shadows from banners, tables, boxes and tabs, each with just a subtle amount of shadow and blur, but apparently enough for IE9 to get all moody.

楠木可依 2024-10-27 03:54:22

Chrome 开发工具曾经包含一个 CSS 选择器分析器,用于执行此类操作。您可以在此博文中查看它的屏幕截图

Chrome 团队在 Chrome 30 中撤回了该功能,声明如下:

对于绝大多数在分析器实现时速度很慢的常见选择器来说,CSS 选择器匹配现在相当快。这次也包含在时间轴“重新计算样式”事件中。

因此,我相信 CSS 选择器分析器并不像以前那样有用,并且可以安全地删除。这也将减少开发人员尝试对已经很快的选择器进行微优化的比例。

您可以尝试使用旧版本的 Chrome 来深入研究该问题,但我建议您查看 时间轴选项卡”将显示 Chrome 计算样式(选择器性能受到影响的地方)、布局和绘制页面所花费的时间。

The Chrome dev tools used to contain a CSS Selector Profiler for doing just this sort of thing. You can see screen shots of it in this blog post.

The Chrome team pulled the feature in Chrome 30 stating that:

CSS selector matching is now reasonably fast for the absolute majority of common selectors that used to be slow at the time of the profiler implementation. This time is also included into the Timeline "Recalculate Style" event.

As such, I believe the CSS selector profiler is not as useful as it [might have been] used to and can safely be dropped. This will also reduce the fraction of developers trying to micro-optimize already fast selectors.

You could try to use an old version of Chrome to dig into the issue, but I'd recommend taking a look at the Timeline tab of the current version of Chrome dev tools with will show you how long Chrome has taken to calculate styles (where selector performance is affected), layout and paint the page.

树深时见影 2024-10-27 03:54:22

Opera 正在其分析器中试验 CSS 分析。

可以按照本页上的步骤启用它。
然后打开分析器,开始分析,并刷新您要分析的页面。
渲染完成后停止分析,然后将显示结果。

Opera is experimenting with css profiling in its profiler.

It can be enabled following the steps on this page.
Then open the profiler, start profiling, and refresh the page you wish to analyze.
Stop profiling after rendering finishes, then the results will be shown.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文