How to run jquery function on every page load
(function ($) {
  Drupal.behaviors.custom_scripts = {
    attach: function (context) {

      //write your custom code

    }
  }
})(jQuery);


Along with this for the first time you have to clear cache, and this will work in all pages and all the times.