{"id":9306,"date":"2021-09-29T13:22:05","date_gmt":"2021-09-29T13:22:05","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=9306"},"modified":"2021-09-29T13:22:07","modified_gmt":"2021-09-29T13:22:07","slug":"javascript-where-to-use-javascript-code","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/","title":{"rendered":"JavaScript : Where to use javaScript code"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">JavaScript code use in following  :<\/h3>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Between the body tag of html<\/strong><\/li><li><strong>Between the head tag of html<\/strong><\/li><li><strong>In .js file (external javaScript)<\/strong><\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">1. JavaScript use between html body tag :<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example of javaScript using inside html between body tag.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/b3adcb37910e12eb873a41c8a6b3548c.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">Output :- Hello World<\/h4>\n\n\n\n<h3 class=\"wp-block-heading\">2. JavaScript use between head tag in html :<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example to use javaScript between head tag in html.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/be67ab438fea34845da19ce966a8a33e.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">Output :<\/h4>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"492\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png\" alt=\"\" class=\"wp-image-9310\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-300x144.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-768x369.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1536x739.png 1536w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js.png 1907w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3. External JavaScript file :<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We can create external JavaScript file and embed it in many html page. If you want to run the same\u00a0<strong>JavaScript<\/strong>\u00a0on several pages in a web site, you should create an\u00a0<strong>external<\/strong>\u00a0<strong>JavaScript<\/strong>\u00a0<strong>file<\/strong>, instead of writing the same script over and over again.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">message.js <\/h4>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/0e11e819cc715ed4cef04554e711242f.js\"><\/script>\n\n\n\n<h4 class=\"wp-block-heading\">index.html<\/h4>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vikash-cotocus\/7a3420785b7ee4571c7fb2c7eddb311d.js\"><\/script>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"441\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss-1024x441.png\" alt=\"\" class=\"wp-image-9311\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss-1024x441.png 1024w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss-300x129.png 300w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss-768x331.png 768w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss-1536x662.png 1536w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/jss.png 1822w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript code use in following : Between the body tag of html Between the head tag of html In .js [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[6861,545,6860,6859,5095,6858,6856,373,593,213,670,6857],"class_list":["post-9306","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-external-javascript-use-code","tag-how","tag-inside-head-tag-javascript-use","tag-inside-html-tag-use-javascript","tag-javascript","tag-javascript-code-use","tag-javascript-example","tag-perforce","tag-process","tag-tutorial","tag-what","tag-where-to-use-javascript-code"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript : Where to use javaScript code - scmGalaxy<\/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.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript : Where to use javaScript code - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"JavaScript code use in following : Between the body tag of html Between the head tag of html In .js [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-29T13:22:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-29T13:22:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png\" \/>\n<meta name=\"author\" content=\"vikashdev k\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"vikashdev k\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/\"},\"author\":{\"name\":\"vikashdev k\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"headline\":\"JavaScript : Where to use javaScript code\",\"datePublished\":\"2021-09-29T13:22:05+00:00\",\"dateModified\":\"2021-09-29T13:22:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/\"},\"wordCount\":116,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/js-1024x492.png\",\"keywords\":[\"External javaScript use code\",\"How\",\"inside head tag javaScript use\",\"inside html tag use javaScript\",\"Javascript\",\"javaScript code use\",\"javascript example\",\"Perforce\",\"Process\",\"Tutorial\",\"What\",\"where to use javaScript code\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/\",\"name\":\"JavaScript : Where to use javaScript code - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/js-1024x492.png\",\"datePublished\":\"2021-09-29T13:22:05+00:00\",\"dateModified\":\"2021-09-29T13:22:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/js.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/js.png\",\"width\":1907,\"height\":917},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-where-to-use-javascript-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript : Where to use javaScript code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ec4d1004b3acffc7df65899e880c7515\",\"name\":\"vikashdev k\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g\",\"caption\":\"vikashdev k\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/vikashdev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript : Where to use javaScript code - scmGalaxy","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.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript : Where to use javaScript code - scmGalaxy","og_description":"JavaScript code use in following : Between the body tag of html Between the head tag of html In .js [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/","og_site_name":"scmGalaxy","article_published_time":"2021-09-29T13:22:05+00:00","article_modified_time":"2021-09-29T13:22:07+00:00","og_image":[{"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png","type":"","width":"","height":""}],"author":"vikashdev k","twitter_card":"summary_large_image","twitter_misc":{"Written by":"vikashdev k","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/"},"author":{"name":"vikashdev k","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"headline":"JavaScript : Where to use javaScript code","datePublished":"2021-09-29T13:22:05+00:00","dateModified":"2021-09-29T13:22:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/"},"wordCount":116,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png","keywords":["External javaScript use code","How","inside head tag javaScript use","inside html tag use javaScript","Javascript","javaScript code use","javascript example","Perforce","Process","Tutorial","What","where to use javaScript code"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/","name":"JavaScript : Where to use javaScript code - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js-1024x492.png","datePublished":"2021-09-29T13:22:05+00:00","dateModified":"2021-09-29T13:22:07+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2021\/09\/js.png","width":1907,"height":917},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-where-to-use-javascript-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"JavaScript : Where to use javaScript code"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/ec4d1004b3acffc7df65899e880c7515","name":"vikashdev k","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/738fe2694a5769295d6bbe57066232fcf8351e09ce1090f200c7b34f770fa61b?s=96&d=mm&r=g","caption":"vikashdev k"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/vikashdev\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=9306"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9306\/revisions"}],"predecessor-version":[{"id":9312,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/9306\/revisions\/9312"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=9306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=9306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=9306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}