{"id":18,"date":"2019-03-17T18:20:43","date_gmt":"2019-03-17T18:20:43","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/javascript\/?p=18"},"modified":"2020-08-06T06:01:56","modified_gmt":"2020-08-06T06:01:56","slug":"02-javascript-script-placement","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/","title":{"rendered":"JavaScript &#8211; Script Placement"},"content":{"rendered":"<p>In <a href=\"https:\/\/www.kindsonthegenius.com\/javascript\/javascript-program-syntax\/\">Tutorial 2<\/a>, we created a html file and placed the script in the &lt;body&gt; &lt;\/body section of the html file. But in this lesson, we are going to see various ways we can place the JavaScript code. We would look at four ways:<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"&quot;#t1\">Script in the &lt;head&gt; section<\/a><\/li>\n<li><a href=\"&quot;#t2\">Script in &lt;body&gt; section<\/a><\/li>\n<li><a href=\"&quot;#t3\">Script in both &lt;body&gt; and &lt;head&gt; section<\/a><\/li>\n<li><a href=\"&quot;#t4\">Script in External Files<\/a><\/li>\n<li><a href=\"&quot;#t5\">Quiz<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s now see how these works.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Script in the &lt;head&gt; section<\/strong><\/h4>\n<p>Now, you can also place the &lt;script&gt;&lt;\/script&gt; tag inside the &lt;head&gt;&lt;\/head&gt; section of the html page.<\/p>\n<p>So try it. Move with the same code we wrote in Tutorial 2, move the &lt;script&gt;&lt;\/script&gt; tag into the head section. That is below the &lt;title&gt;&lt;\/title&gt; tag.<\/p>\n<p>You will have it a shown below.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;html&gt;<\/span>\r\n\r\n<span style=\"color: #007700;\">&lt;head&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;title&gt;<\/span>Your Second Program<span style=\"color: #007700;\">&lt;\/title&gt;<\/span>\r\n\t\r\n\t<span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">language =<\/span> <span style=\"background-color: #fff0f0;\">\"javascript\"<\/span> <span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span><span style=\"color: #007700;\">&gt;<\/span>\r\n   \r\n\t<span style=\"color: #007020;\">document<\/span>.write(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript. Enjoy!\"<\/span>)\r\n\t\r\n   <span style=\"color: #007700;\">&lt;\/script&gt;<\/span>\r\n   \r\n<span style=\"color: #007700;\">&lt;\/head&gt;<\/span>\r\n\r\n<span style=\"color: #007700;\">&lt;body&gt;<\/span>   \r\n   \r\n<span style=\"color: #007700;\">&lt;\/body&gt;<\/span>\r\n\r\n<span style=\"color: #007700;\">&lt;\/html&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you create and view this file, then it works fine as well.<\/p>\n<p>However, this is normally used when you want the script to execute on some event. For instance, when a user clicks a button. In this case, you put the code inside a function. Then you call this function on button click event. To to this you simply assign the name of the function as value to the onclick attribute of a button. The complete code is given below.<\/p>\n<p>Try\u00a0 it to see how it works<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;html&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;head&gt;<\/span>      \r\n      <span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span><span style=\"color: #007700;\">&gt;<\/span>\r\n         <span style=\"color: #888888;\">&lt;!--<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">function<\/span> greeting() <span style=\"color: #ff0000; background-color: #ffaaaa;\">{<\/span>\r\n               alert(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript\"<\/span>)\r\n            }\r\n         <span style=\"color: #888888;\">\/\/--&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;\/script&gt;<\/span>     \r\n   <span style=\"color: #007700;\">&lt;\/head&gt;<\/span>\r\n   \r\n   <span style=\"color: #007700;\">&lt;body&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;input<\/span> <span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"button\"<\/span> <span style=\"color: #0000cc;\">onclick =<\/span> <span style=\"background-color: #fff0f0;\">\"greeting()\"<\/span> <span style=\"color: #0000cc;\">value =<\/span> <span style=\"background-color: #fff0f0;\">\"Greeting\"<\/span> <span style=\"color: #007700;\">\/&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/body&gt;<\/span>  \r\n<span style=\"color: #007700;\">&lt;\/html&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>So, in the code above, when the user clicks on the button, then the function in the &lt;head&gt; section will execute.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Script in &lt;body&gt; section<\/strong><\/h4>\n<p>This is similar to the code we wrote in<a href=\"https:\/\/www.kindsonthegenius.com\/javascript\/javascript-program-syntax\/\" target=\"_blank\" rel=\"noopener noreferrer\"> Tutorial 2.<\/a> This means that the code would execute immediately the page loads. Sometimes you may need a code to generate the content of the web page. In this case, you place it in the &lt;body&gt; section. It runs immediately the page is opened.<\/p>\n<p>Try the code below to see how it work.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;html&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;head&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/head&gt;<\/span>\r\n   \r\n   <span style=\"color: #007700;\">&lt;body&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span><span style=\"color: #007700;\">&gt;<\/span>\r\n         <span style=\"color: #888888;\">&lt;!--<\/span>\r\n            <span style=\"color: #007020;\">document<\/span>.write(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript\"<\/span>)\r\n            <span style=\"color: #007020;\">document<\/span>.write(<span style=\"background-color: #fff0f0;\">\"This is a second line of code\"<\/span>) \r\n         <span style=\"color: #888888;\">\/\/--&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;\/script&gt;<\/span>\r\n      \r\n      <span style=\"color: #007700;\">&lt;p&gt;<\/span>This text appear in the body of the page <span style=\"color: #007700;\">&lt;\/p&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/body&gt;<\/span>\r\n<span style=\"color: #007700;\">&lt;\/html&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Script in both &lt;body&gt; and &lt;head&gt; section<\/strong><\/h4>\n<p>It is also possible to place the &lt;script&gt; tags both in the body and in the &lt;head&gt; section. I recommend you try it yourself.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;html&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;head&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span><span style=\"color: #007700;\">&gt;<\/span>\r\n         <span style=\"color: #888888;\">&lt;!--<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">function<\/span> greeting() <span style=\"color: #ff0000; background-color: #ffaaaa;\">{<\/span>\r\n               alert(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript\"<\/span>)\r\n            }\r\n         <span style=\"color: #888888;\">\/\/--&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;\/script&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/head&gt;<\/span>\r\n   \r\n   <span style=\"color: #007700;\">&lt;body&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span><span style=\"color: #007700;\">&gt;<\/span>\r\n         <span style=\"color: #888888;\">&lt;!--<\/span>\r\n            <span style=\"color: #007020;\">document<\/span>.write(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript\"<\/span>)\r\n         <span style=\"color: #888888;\">\/\/--&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;\/script&gt;<\/span>\r\n      \r\n      <span style=\"color: #007700;\">&lt;input<\/span> <span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"button\"<\/span> <span style=\"color: #0000cc;\">onclick =<\/span> <span style=\"background-color: #fff0f0;\">\"greeting()\"<\/span> <span style=\"color: #0000cc;\">value =<\/span> <span style=\"background-color: #fff0f0;\">\"Say Hello\"<\/span> <span style=\"color: #007700;\">\/&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/body&gt;<\/span>\r\n<span style=\"color: #007700;\">&lt;\/html&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Script in External Files<\/strong><\/h4>\n<p>In this case, you place your JavaScript code in an external file. This is necessary if you need to use the same script in many pages. Instead of writing the script in the pages, you simply write it in just one single file. Then you can import this file into any page you want to apply the script.<\/p>\n<p>Create a file with the content below and name it myfile.js.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">function<\/span> greeting() {\r\n   alert(<span style=\"background-color: #fff0f0;\">\"Welcome to JavaScript\"<\/span>)\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Then create a html file with content below. Both files should be in the same folder.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;html&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;head&gt;<\/span>\r\n      <span style=\"color: #007700;\">&lt;script <\/span><span style=\"color: #0000cc;\">type =<\/span> <span style=\"background-color: #fff0f0;\">\"text\/javascript\"<\/span> <span style=\"color: #0000cc;\">src =<\/span> <span style=\"background-color: #fff0f0;\">\"myfile.js\"<\/span> <span style=\"color: #007700;\">&gt;&lt;\/script&gt;<\/span>\r\n   <span style=\"color: #007700;\">&lt;\/head&gt;<\/span>\r\n   \r\n   <span style=\"color: #007700;\">&lt;body&gt;<\/span>\r\n      This is the body of the page\r\n   <span style=\"color: #007700;\">&lt;\/body&gt;<\/span>\r\n<span style=\"color: #007700;\">&lt;\/html&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Then open the html file. You will notice that it displays an alert as defined in the<em> myfile.js<\/em> script file.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. Quiz<\/strong><\/h4>\n<p>Here is a quiz for you:<\/p>\n<p>What is the role of the &lt;title&gt;&lt;\/title&gt; tag?<\/p>\n<p>Leave your answer in the comment box below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Tutorial 2, we created a html file and placed the script in the &lt;body&gt; &lt;\/body section of the html file. But in this lesson, &hellip; <\/p>\n","protected":false},"author":395,"featured_media":20,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-18","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript - Script Placement - JavaScript Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript - Script Placement - JavaScript Tutorial\" \/>\n<meta property=\"og:description\" content=\"In Tutorial 2, we created a html file and placed the script in the &lt;body&gt; &lt;\/body section of the html file. But in this lesson, &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/\" \/>\n<meta property=\"og:site_name\" content=\"JavaScript Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-17T18:20:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-06T06:01:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"912\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"JavaScript &#8211; Script Placement\",\"datePublished\":\"2019-03-17T18:20:43+00:00\",\"dateModified\":\"2020-08-06T06:01:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/\"},\"wordCount\":539,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/wp-content\\\/uploads\\\/sites\\\/6\\\/2019\\\/03\\\/Script-Placement.jpg\",\"articleSection\":[\"JavaScript Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/\",\"name\":\"JavaScript - Script Placement - JavaScript Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/wp-content\\\/uploads\\\/sites\\\/6\\\/2019\\\/03\\\/Script-Placement.jpg\",\"datePublished\":\"2019-03-17T18:20:43+00:00\",\"dateModified\":\"2020-08-06T06:01:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/wp-content\\\/uploads\\\/sites\\\/6\\\/2019\\\/03\\\/Script-Placement.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/wp-content\\\/uploads\\\/sites\\\/6\\\/2019\\\/03\\\/Script-Placement.jpg\",\"width\":912,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/02-javascript-script-placement\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript &#8211; Script Placement\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/\",\"name\":\"JavaScript Tutorial\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/javascript\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript - Script Placement - JavaScript Tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript - Script Placement - JavaScript Tutorial","og_description":"In Tutorial 2, we created a html file and placed the script in the &lt;body&gt; &lt;\/body section of the html file. But in this lesson, &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/","og_site_name":"JavaScript Tutorial","article_published_time":"2019-03-17T18:20:43+00:00","article_modified_time":"2020-08-06T06:01:56+00:00","og_image":[{"width":912,"height":500,"url":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"JavaScript &#8211; Script Placement","datePublished":"2019-03-17T18:20:43+00:00","dateModified":"2020-08-06T06:01:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/"},"wordCount":539,"commentCount":3,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg","articleSection":["JavaScript Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/","url":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/","name":"JavaScript - Script Placement - JavaScript Tutorial","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg","datePublished":"2019-03-17T18:20:43+00:00","dateModified":"2020-08-06T06:01:56+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-content\/uploads\/sites\/6\/2019\/03\/Script-Placement.jpg","width":912,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/02-javascript-script-placement\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/javascript\/"},{"@type":"ListItem","position":2,"name":"JavaScript &#8211; Script Placement"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/#website","url":"https:\/\/www.kindsonthegenius.com\/javascript\/","name":"JavaScript Tutorial","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/javascript\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/javascript\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/javascript\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":3,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/posts\/18\/revisions\/109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/media\/20"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/javascript\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}