Jquery CPU usage

cpu-usage, javascript, jquery, jquery-animate

Solution

It's using up CPU resources because you're asking the browser to repaint an image many times per second over a long period of time. That's not free.

Problem

I am using Jquery to make an image scroll across my page horizontally. The only problem is that it uses a serious amount of cpu usage. Up to 100% on a single core laptop in firefox. What could cause this??? Jquery ``` <script> jQuery(document).ready(function() { $(".speech").animate({backgroundPosition: "-6000px 0px"}, 400000, null); }); </script> ``` CSS ``` .speech { /*position:fixed;*/ top:0; left:0px; height:400px; width:100%; z-index:-1; background:url(/images/speech.png) -300px -500px repeat-x; margin-right: auto; margin-left: auto; position: fixed; } ``` HTML ``` <div class="speech"></div> ```

Original source