一般的な方法ですが、公開する前には、できるだけ外部ファイルまとめたほうがよい。
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-style-type" content="text/css"> <meta http-equiv="content-script-type" content="text/javascript"> <script type="text/javascript"> jQueryの処理を記述 </script> <title></title> </head>
一般的な方法です。
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-style-type" content="text/css"> <meta http-equiv="content-script-type" content="text/javascript"> <script type="text/javascript" src=" 外部jsファイルにJavaScrptの処理を記述 "></script> <title></title> </head>
ブログなどでhead要素内に記述できない場合や、外部から読み込むファイルにのjQueryを使用する場合に使用。
<body> (省略) <script type="text/javascript"> jQueryの処理を記述 </script> (省略) </body>
JavaScriptの読み込みを後回しにすることで、HTMLの表示速度を優先することもある。
<body> (省略) <script type="text/javascript"> jQueryの処理を記述 </script> </body> </html>