Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8234639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:33:03+00:00 2026-06-07T18:33:03+00:00

So, I’m using Paul Irish’s requestAnimationFrame to make a sidebar sticky on the page.

  • 0

So, I’m using Paul Irish’s requestAnimationFrame to make a sidebar “sticky” on the page. I’ve found in at least webkit browsers this lends a vast performance improvement over other solutions like Waypoints. However, I’ve noticed on Firefox that when I start to scroll the page CPU goes through the roof and the page is immensely slow due to this. Am I implementing this wrong, or will I need to use another method for Firefox?

    (function() {
    var lastTime = 0;
    var vendors = ['ms', 'moz', 'webkit', 'o'];
    for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
        window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
        window.cancelAnimationFrame =
          window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
    }

    if (!window.requestAnimationFrame)
        window.requestAnimationFrame = function(callback, element) {
            var currTime = new Date().getTime();
            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
            var id = window.setTimeout(function() { callback(currTime + timeToCall); },
              timeToCall);
            lastTime = currTime + timeToCall;
            return id;
        };

    if (!window.cancelAnimationFrame)
        window.cancelAnimationFrame = function(id) {
            clearTimeout(id);
        };
}());

window.widget_is_sticky = false;
window.widget_is_locked = false;

$(function(){

  (function animloop() {
    requestAnimationFrame(animloop);
    if (adjust_networth) {
      if (self.pageYOffset) {
        yScroll = self.pageYOffset;
      } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
      } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
      }
      update_networth_position(yScroll);
    }
  })();
});

// Separate file written in CoffeeScript
window.update_networth_position = ( offset ) ->
  if offset >= 259
    if !window.widget_is_sticky
      window.widget_is_sticky = true
      $('.widgets').addClass 'sticky'
    else if !window.widget_is_locked and widget_is_at_boundary(offset)
      window.widget_is_locked = true
      $('.widgets').addClass 'locked'
    else if !widget_is_at_boundary(offset) and window.widget_is_locked
      window.widget_is_locked = false
      $('.widgets').removeClass 'locked'
  else
    return false if !window.widget_is_sticky

    $('.widgets').removeClass 'sticky'
    window.widget_is_sticky = false


widget_is_at_boundary = ( offset ) ->
  offset = offset - $('section.top-section').outerHeight(true)
  maximum_height = $('section.main-content div.content:first-child').outerHeight(true)
  widget_height  = $('section.main-content .widgets').outerHeight(true)

  if (offset + widget_height) > maximum_height
    return true
  else
    return false

Any help is greatly greatly appreciated! I am also open to completely different solutions for how to approach this (but Waypoints wasn’t performant enough to work nicely).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:33:05+00:00Added an answer on June 7, 2026 at 6:33 pm

    Sorry about this, false alarm. Turns out the performance hit is coming from a background css technique I was using. requestAnimationFrame is safe this time 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.