title: How to call a jQuery function as fast as possible?
body: <p>So I am using a PHP only pagination method shown here:
  <a href="https://stackoverflow.com/questions/31265095/how-to-create-ajax-pagination-without-a-database/31265537?noredirect=1#answer-31265537">How to create AJAX pagination without a database?</a>
  And I have the following code for my menu:</p>
  
  <pre><code>$(document).ready(function(){
      $("#my-btn").click(function(event) {
          event.preventDefault();
          $('html, body').animate({
              scrollTop: $("#div").offset().top
          }, 2000, "swing", function(){
              $("#shiny").effect('shake', {times: 1, direction: 'left', distance: 5}, 300);
          });
      });
  });
  </code></pre>
  
  <p>Since only a portion of the page changes I have devided the menu links to bring the user into different parts of the page. For example if the first page contains element <code>#div</code> the user clicks on the global template element <code>#my-btn</code> (from the menu) and the screen scrolls and the text shakes once. But what if the button actually links to another page? I want that same effect to execute even when on another page that contains different element, for example <code>#second-div</code>.</p>
  
  <p>So I wonder if there is a way to execute this function once the user clicks on a menu item and moves from <code>index.php?limit=1&amp;amp;page=0</code> to <code>index.php?limit=1&amp;amp;page=1</code> or vise-versa.</p>