Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I changed the background of my discussion forum using the CSS below

http://forum.antinovaordemmundial.com

html {
    background: url(http://antinovaordemmundial.com/mystuff/logo_blog.jpg) no-repeat center center fixed;
    background-image: url(http://antinovaordemmundial.com/mystuff/logo_blog.jpg);
    background-repeat-x: no-repeat;
    background-repeat-y: no-repeat;
    background-attachment: fixed;
    background-position-x: 50%;
    background-position-y: 50%;
    background-origin: initial;
    background-clip: initial;
    background-color: initial;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

The image is 1600x711 and 88k. The scrolling of the pages are now very slow. Is the CSS problematic or the image should be smaller somehow?

Edit: I tried changing to:

body {        
    color: #000;
    font-family: Verdana, Arial, Sans-Serif;
    font-size: 13px;
    text-align: center; /* IE 5 fix */
    line-height: 1.4;
    background-attachment: fixed;
    background-clip: initial;
    background-color: #51010E;
    background-image: url(http://antinovaordemmundial.com/mystuff/logo_blog.jpg);
    background-origin: initial;
    background-position: initial initial;
    background-repeat: initial initial;
    margin-bottom: 0;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
}

But it is still very slow on scrolling.

like image 389
Emerson Avatar asked Aug 11 '11 23:08

Emerson


6 Answers

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

like image 153
user2810762 Avatar answered Oct 16 '22 20:10

user2810762


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.

like image 39
kossdav Avatar answered Oct 16 '22 21:10

kossdav


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.

like image 6
John Stimac Avatar answered Oct 16 '22 21:10

John Stimac


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.

like image 2
TNF Avatar answered Oct 16 '22 19:10

TNF


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.

like image 1
WPExplorer Avatar answered Oct 16 '22 20:10

WPExplorer


make the background-size to 99.9% not 100% or cover in the case of the fixed attachment

background-size : 99.9%;
like image 1
Karbs Avatar answered Oct 16 '22 21:10

Karbs