<script src="script.js">A</script>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<! -- HTML GOES HERE. JAVASCRIPT COMES ASF HTML -->
<script language = "javaikpt">
confirm(ok or Cancel?)
</script>
<body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>A first script</title>
<script langjage = "javascript">
confirm("ok or cancel?")
</script>
</head>
<body>
<body>
</html>
https://www.homeandlearn.co.uk/javascript/javascript_tag_placement.html ↗2023年 12月 01日 16時21分
링커주소 복사 12월01일 금 16時26分 https://twitter.com/intent/tweet?text=Great+article+by+%40BenNadel+-+Dynamically+Creating+Script+Tags+With+Umbrella+JS+https%3A%2F%2Fwww.bennadel.com%2Fgo%2F4192
https://www.bennadel.com/blog/4192-dynamically-creating-script-tags-with-umbrella-js.htm
https://www.kirupa.com/html5/loading_script_files_dynamically.htm ↙
<!DOCTYPE html>
<html>
<head-<!DOCTYPE html>
<html>
<head>
<title>Dynamic Script Loading</title>
<style>
body {
padding: 50px;
background-color: #EAC5D8;
}
h1 {
font-family: sans-serif;
font-size: 128px;
margin: 0;
line-height: 1em;
font-weight: bold;
color: #D68FB5;
}
</style>
</head>
<body>
<h1>I am <br>in your<br> code!</h1>
<script>
let myCoolCode = document.createElement("script");
myCoolCode.setAttribute("src", "https://www.kirupa.com/js/easing.js");
document.body.appendChild(myCoolCode);
</script>
</body>
</html>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
<p id="demo">A Paragraph.</p>
<button type="button" xxxxonclick="myFunction()">Try it</button>
</body>
</html>
Running Dependent Code After Our Script File Has Loaded We just have one last tidbit around dealing with dynamic script files that we will look at before wrapping things up. It is common to load an external script file and then call a function (or rely on something from the loaded script) immediately afterwards. Below is one such example of what that this traditionally looks like:
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Script Loading</title>
<style>
body {
padding: 50px;
background-color: #EAC5D8;
}
h1 {
font-family: sans-serif;
font-size: 128px;
margin: 0;
line-height: 1em;
font-weight: bold;
color: #D68FB5;
}
</style>
<script>
let myCoolCode = document.createElement("script");
myCoolCode.setAttribute("src", "https://www.kirupa.com/js/easing.js");
myCoolCode.setAttribute("async", "false");
let head = document.head;
head.insertBefore(myCoolCode, head.firstElementChild);
</script>
</head>
<body>
<h1>I am <br>in your<br> code!</h1>
</body>
</html>
<!DOCTYPE html> JavaScript tag
<html>
<head>
</head>
<body>
<body>
</html>
indexc_html 기본
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<body>
</html>
<script src="script.js">A</script>