Auto Copyright Year was, but now not working

Hi everyone.
I have a copyright auto-year small script I got from this community many years ago. Has been working fine, but just now isn’t.

The script (below) has always been in the Site Settings area (before /body>) and that hasn’t changed.
The HTML date part {year} is span-wrapped and style linked as it’s always been.

Anyone tell me what’s gone wrong please?

<script>
Webflow.push(function() {
  $('.copyright-year').text(new Date().getFullYear());
});
</script>

Popular topic today.

Not certain why these constructions worked before, as they probably shouldn’t have, and probably didn’t on slower networks - but something’s changed to make them consistently fail.

In essence you need to wait for the Webflow object to exist before your code executes. This is the accepted approach;

<script>
  var Webflow = Webflow || [];
  Webflow.push(function() {
    // your code here
  });
</script>
1 Like

I had the same problem earlier dunno if Weblow had some updates that creates bug or new instructions how to use it but what i did was to use vanilla JS to execute the same function in your case you can use:

<script>
document.addEventListener('DOMContentLoaded', function() {
    document.querySelector('.copyright-year').textContent = new Date().getFullYear();
});
</script>

I see, so this is how. thanks I’ll try this out as well

Thank you VERY much for responding, and providing the solution that worked!!!

Regards,
KJ