Reputation: 4253
I have a menu that is included by php in all my pages. to avoid adding <script
to each of this pages I decided to place the script tag right after this menu close div, so php include the menu and its script.
I don't want this script to stops parsing the other HTML on my page, I know the best practise is to place it before the closing body tag.
The question here is, is it blocking my page? or it will only block if I put it on head or use the $(document).ready(function() {
?
<html>
<head>
<title>My Page</title>
</head>
<body>
...html
<div id="menu">itens</div>
<script type="text/javascript" src="script.js"></script>
...html
</body>
</html>
the script.js
$("#menu").click(function() {
$("#message").show();
$("#back").show();
});
Upvotes: 0
Views: 930
Reputation: 131
If you want to load this script after full page loadup you can use defer keyword.
<script type="text/javascript" src="script.js" defer></script>
defer will start loading this js file after execution of html and other js files.
Upvotes: 2