Does it matter if I use multiple $ (document) .ready (function () {in one html page
No, that doesn't matter, and in some cases (reading: a lot) the right way. However, as always, I would like to give some (useful) pointers:
As you mentioned in the comment, technically adding a call file to </body> means that you basically don't need to use $(document).ready() . I personally try to avoid as much as I can, since jQuery is not as strict as JS (meaning: most scripts work without $(document).ready() ).
[EDIT: this part of my answer is inaccurate, see comments below] Also, it is not practical to add jquery inside in the footer or even in the <body> . This is technically wrong, but if you are dealing with cms-like software or some template function, then you want jQuery to be enabled on all pages. OR you can just call it your old school knowledge.
Since you want to call Photos.js and Animations.js in the footer, I assume that they are not the correct plugins. If you want to make your code more rigid, then assemble them into the correct plugin. Then you can add plugins to the header and have one footer file in which you assign plugins to elements (read: activate them.) Here is a quick guide on how to create your own plugins.
In addition, if you have several JS files that should be included in the page. Then you can make your code $.getScript() using $.getScript() . You must add jQuery first, as always, but you can call other files in a single <script> . It looks more neat, and it seems to be a little faster (at least in my own head.) I will give you a small example:
<html> <head> <script type="text/javascript" src="jquery.js"></script> </head> <body> <script type="text/javascript"> $.getScript('js/Photos.js'); $.getScript('js/Animations.js'); </script> </body> </html>
source share