When compressing the js script, an error occurs:
SyntaxError: Unexpected token: name ($ content)
Before compression, the script works fine.
(function () { let $content = $('.s-content'); let $back2top = $('.back-to-top'); let $windowHeight; let contentBottom; function onScrollWindow() { let offsetY = window.pageYOffset; if (offsetY - $content.offset().top > 100 && !$back2top.hasClass('back-to-top_visible')) { $back2top.addClass('back-to-top_visible'); } else { if (offsetY - $content.offset().top < 100 && $back2top.hasClass('back-to-top_visible')) { $back2top.removeClass('back-to-top_visible'); } } if (offsetY + $windowHeight >= contentBottom && !$back2top.hasClass('back-to-top_pinned')) { $back2top.addClass('back-to-top_pinned'); } else { if (offsetY + $windowHeight < contentBottom && $back2top.hasClass('back-to-top_pinned')) { $back2top.removeClass('back-to-top_pinned'); } } } function onResizeWindow() { $windowHeight = $(window).height(); contentBottom = $content.offset().top + $content.height() + 25; } $(document).ready(function () { if ($content.length < 1 || $back2top.length < 1) { return; } $windowHeight = $(window).height(); contentBottom = $content.offset().top + $content.height() + 25; document.addEventListener('scroll', function () { onScrollWindow(); }, true); window.addEventListener('resize', function () { onResizeWindow(); }, true); }); })();
let- Grundy