this is what im trying to do
<script type="text/javascript" src="resources/application.js"></script>
<script type="text/javascript" >
$(document).ready(createHeader());
$(document).ready(scriptSet());
</script>
id like to avoid having to separate the two, and while generally i see script links only inside the header the document.ready functions dont seem to work when put there. However, everything seems to work completely fine when placed at the end of the body, so would this cause any problems or is this fine?
Functionally, as long as you enclose your code inside a
$(document).ready(function(){ });and it comes after the jQuery file includes, it does not matter if it’s in theheador thebody.$(document).readyensures that the DOM is fully loaded before any script is executed.HOWEVER, putting all of your script includes and scripts at the bottom of the
bodyis best for loading performance.This article explains it nicely.
Example: