My fixed background made scrolling the site very slow, what can I do to improve it?

怎甘沉沦 提交于 2019-11-28 07:36:29

The problem goes away for me when I remove the background-size property. I think it was the scaling of the large image that was causing the problem. If that doesn't work, just remove the background image altogether. However, I've never heard of a large background image causing lag before.

I had the same problem and solved it using this jQuery plugin : http://srobbin.com/jquery-plugins/jquery-backstretch/

It doesn't use any CSS3 property but it works fine and doesn't have any performance issue on Chrome 13 or Firefox 6.

I thought I would just contribute here. Rather than use background-attachment: fixed; use :before and position: fixed; problem sorted. I ran into this same problem.

Read more here: http://fourkitchens.com/blog/article/fix-scrolling-performance-css-will-change-property

Also, applying the following style to the html tag improves the frame rate significantly in WebKit browsers, Chrome included:

-webkit-transform: translate3d(0,0,0);

This works in all cases with (large) background photos and choppy scrolling as far as I can tell.

Compressing the image (reducing the size), solved my issue, I highly recommend using a tool like Radical Image Optimization Tool (RIOT), very effective and easy.

On linux, this can be done using GIMP , you can also remove image's metadata to reduce the size, use tool like exiftool.

The issue is actually with the background-attachment fixed value if you change it to background-attachment: scroll for mobile devices it should fix the lag.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!