Jump to content

What does this JV code do?

Recommended Posts

Site URL: https://gregorylassale.com/

 

Site URL: 

After double checking all the code on my site, I am left with a few lines of code in the header whose purpose I can't remember.

<script>
  window.oldSetTimeout = window.setTimeout;
  window.setTimeout = function(code, delay) {
    if (delay == 5000) {
      delay = 5500;
    }
    var retval = window.oldSetTimeout(code, delay);
    return retval;
  };
  window.oldSetInterval = window.setInterval;
  window.setInterval = function(code, delay) {
    if (delay == 5000) {
      delay = 5500;
    }
    var retval = window.oldSetInterval(code, delay);
    return retval;
  };
  </script>

 

Could a dev please interpret the code above for me and describe what it does? I want to make sure it belongs to an old plugin/feature I no longer use and that it's safe to delete. 

Thanks!

Link to comment
  • Replies 3
  • Views 714
  • Created
  • Last Reply
On 4/7/2021 at 7:51 PM, GregLassale said:

Site URL: https://gregorylassale.com/

 

 

Site URL: 

After double checking all the code on my site, I am left with a few lines of code in the header whose purpose I can't remember.


<script>
  window.oldSetTimeout = window.setTimeout;
  window.setTimeout = function(code, delay) {
    if (delay == 5000) {
      delay = 5500;
    }
    var retval = window.oldSetTimeout(code, delay);
    return retval;
  };
  window.oldSetInterval = window.setInterval;
  window.setInterval = function(code, delay) {
    if (delay == 5000) {
      delay = 5500;
    }
    var retval = window.oldSetInterval(code, delay);
    return retval;
  };
  </script>

 

Could a dev please interpret the code above for me and describe what it does? I want to make sure it belongs to an old plugin/feature I no longer use and that it's safe to delete. 

Thanks!

It just defined  the timer without the use of it, could you remove it and tell us if there is error in console panel?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

That is Javascript sometimes abbreviated as JS.

I suggest that if you remove the code that you make a copy somewhere in case you need to restore it.

You can even leave it in place and comment it out until you are sure it is not needed anymore. This is a bit more involved.

<script> and </script> for a particular script

...becomes...

<!-- script> and </script -->

Adding those characters make the script an HTML comment.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

The site seems to be doing fine without that bit of code. That said, I did put it back in and commented it out as it bugs me that I can't identify what it does.

I think it might be part of a fix for a plugin I bought a couple of years that was causing a flicking issue. I emailed the dev to ses if he recognizes the code. 

I've never used the console panel but will look into it and report back if I do set an error. 

Thanks, guys.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.