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

  • Home
  • SEARCH
  • 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 8914941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:51:16+00:00 2026-06-15T04:51:16+00:00

I created this piece of code to increase my webpage performance. If autoplay.v.mystart is

  • 0

I created this piece of code to increase my webpage performance.
If autoplay.v.mystart is true, the sliding and animations of 2 slideshows will not be played,I made condition on it. My aim is to stop the animations while user is scrolling and reactivate it while user stopped scrolling, I think it will reduce a webpage load, to make a webpage scroll smoother, as I listened to people say stop unused animations or hide things that’s unused. However, I see it didn’t go smoother, but a bit more laggy. Is it using scroll event listener and timer/cleartimeout will take up a lot of resources too? What is the best way to accomplish my aim , to reduce my webpage load? I am thinking should I remove this code?That will be a waste,I can’t decide

var saviour = {
    '$mywrapper' : $('#wrapper'),
    'mychecked':false,
    run : function(){
        var wrapper_timer;
        saviour.$mywrapper.scroll(function(){
            if(saviour.mychecked==false){
                saviour.mychecked = true;
                autoplay.v.mystart = false;
                clearTimeout(wrapper_timer);
                setTimeout(function(){saviour.mychecked=false},1000);
                wrapper_timer = setTimeout(function(){
                autoplay.v.mystart = true;
                console.log('autoplay restart')
                },4000);
                console.log('check');
            }
        });
    }
}
saviour.run();
  • 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-15T04:51:17+00:00Added an answer on June 15, 2026 at 4:51 am

    First, here’s a jQuery addon that provides ‘scrollstart’ and ‘scrollstop’ events, based on this, which was written for an early version of jQuery and needed to be modernized.

    (function($, latency) {
        var special = $.event.special;
        special.scrollstart = {
            setup: function() {
                var timer;
                function handler(evt) {
                    if (timer) {
                        clearTimeout(timer);
                    } else {
                        evt.type = 'scrollstart';
                        $.event.handle.apply(this, arguments);
                    }
                    timer = setTimeout(function() {
                        timer = null;
                    }, latency);
                };
                $(this).on('scroll.start', handler);
            },
            teardown: function() {
                $(this).off('scroll.start');
            }
        };
        special.scrollstop = {
            setup: function() {
                var timer;
                function handler(evt) {
                    var _self = this,
                        _args = arguments;
                    if (timer) {
                        clearTimeout(timer);
                    }
                    timer = setTimeout(function() {
                        timer = null;
                        evt.type = 'scrollstop';
                        $.event.handle.apply(_self, _args);
                    }, latency);
                };
                $(this).on('scroll.stop', handler);
            },
            teardown: function() {
                $(this).off('scroll.stop');
            }
        };
    })(jQuery, 300);
    

    This version :

    • Replaces .bind() and .unbind() with .on() and .off(), plus associated simplification.
    • Allows the latency to be specified as a parameter to the self-executing function wrapper.

    With ‘scrollstart’ and ‘scrollstop’ event detection in place, the application snippet for starting and stopping the animation can be as simple as this :

    $(window).on ('scrollstart', function(e) {
        allowAnim = false;    
        stopAnim();
    }).on ('scrollstop', function(e) {
        allowAnim = true;
        anim();
    }).trigger('scrollstop');
    

    where anim() and stopAnim() are your functions for starting and stopping animation(s) and allowAnim is a boolean var in an outer scope.

    You may want to adjust the latency. I found 300 to be about the minimum acceptable value, and very responsive. Larger A higher value will be less responsive but will better prevent the animation from restarting in mid-scroll.

    DEMO

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

Sidebar

Related Questions

I created a JAR file with my Java program. This piece of code will
Yesterday I created this piece of code that could calculate z^n, where z is
I have this piece of code where a server socket is created and is
I have this piece of code. I want to remove the rows created with
Why is this piece of code not working on Chrome 4.0 but works on
I've created this code, it is supposed to use wordpress metabox functionality to save
I have this piece of code and it's causing NullPointerException private List<Player> playerList; private
Am getting errors in this piece of code; I have placed the error messages
I've got this piece of code: try { using(conn) { conn.UpdateScheduledTaskGuid(taskID, taskGUID); } }
I have this piece of code in my java class mystring = mysuperstring.split(/); I

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.