How to improve JS scroll performance?
<p>I'm working on revamping my website, and the new one can be found on <a href="http://beta.namanyayg.com/" rel="nofollow">http://beta.namanyayg.com/</a></p>

<p>There are mainly two things related to scroll on the site:</p>

<ul>
<li>To check on which 'page' the user is on, by calculating the top offset and scroll position, then adding a class to the page.</li>
<li>To smooth scroll on menu click.</li>
</ul>

<p>I've <em>written code for both, but there is a lot of lag</em>.</p>

<p>The first one almost always results in lagging. The second one, as a result, lags too. I have included a boolean to check if it's smooth scrolling and disabled the normal scroll events then, but there's not much change.</p>

<p>Do you have any advice on how to improve performance so there is no (or at least, less) lag? Thank you in advance! :)</p>

<p>...Or is it not related to JS at all? I've optimized everything else...</p>

<p>EDIT: <strong>Unminified JS at <a href="http://beta.namanyayg.com/js/main.js" rel="nofollow">http://beta.namanyayg.com/js/main.js</a></strong></p>
