If we start from the fact that we start with a simple, single page template from jquery mobile, there is a key bit of information that is omitted. If you want to have globally accessible functions and variables and be able to change the default values ββfor the framework, you need to add your custom script between jquery.js and jquerymobile.js, as shown in their global configuration pages .
<head> ... <script src="jquery.js"></script> <script src="custom-scripting.js"></script> <script src="jquery-mobile.js"></script> ... </head>
When you go from one page to another with integrated ajax-based navigation, everything in custom-scripting.js will still be available to you and can even be used to manage pages as they become available.
If, however, you place the script inside your <div data-role="page"> , you will only have access to execution as long as this page is in place. When you go to another page, that original page will be removed from the DOM and therefore your script. Therefore, you need to either call your script on each page, or put it in a custom script.js. Using a global script would be a much more efficient option, as HTTP requests on mobile devices are the cause of most of the slowdowns.
source share