{"id":50982,"date":"2022-12-22T12:01:09","date_gmt":"2022-12-22T04:01:09","guid":{"rendered":"https:\/\/www.crazydomains.com\/learn\/?p=50931"},"modified":"2022-12-22T12:27:58","modified_gmt":"2022-12-22T04:27:58","slug":"add-javascript-to-wordpress-websites","status":"publish","type":"post","link":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/","title":{"rendered":"How to Insert JavaScript in WordPress Websites"},"content":{"rendered":"<p><span data-contrast=\"auto\">JavaScript is utilised in a wide range of applications, including game development, web application development, and more. It is also a well-established front-end language that continues to grow and provide flexibility to website functions \u2013 especially WordPress. If you have a plugin for a slider, social media links, or responsive navigation menu on your website, someone has to add\u00a0JavaScript to WordPress website plugins to create those effects.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">If you are a WordPress developer accustomed to working with PHP, you may have second thoughts about how to add\u00a0JavaScript to a WordPress website. However, the good news is that JavaScript and PHP share many similarities. They work in various ways and various settings, yet the code you compose isn&#8217;t all that different all the time.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">In this article, we\u2019ll teach you how to simply add JavaScript to a WordPress website. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><b><span data-contrast=\"none\">3 Ways to Add JavaScript to WordPress Websites<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<h3><b><span data-contrast=\"none\">1. Enqueueing Scripts for Themes and Plugins<\/span><\/b><\/h3>\n<p><span data-contrast=\"auto\">The recommended method for adding scripts to a WordPress theme is to queue your scripts and stylesheets because it does not only make it simple to access the list of pre-registered scripts, but it also helps prevent conflict between plugins and themes. If you use a plugin that also uses jQuery and adds jQuery to the head of your document with a script tag, you might end up loading jQuery twice, which is not ideal. That can&#8217;t happen if your scripts are queued.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Enqueuing scripts in WordPress makes it simple to include dependencies from the list of pre-registered scripts, which is one of the best features. The WordPress function reference contains a comprehensive list of scripts. The only thing left to do is to include the handle of the dependency in the arguments of wp_enqueue_script. That&#8217;s it!<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">To give you an idea of how it would look like, refer to the following script:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>function my_add_theme_scripts() {<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> \/\/ stylesheets<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> wp_enqueue_style( &#8216;jquery-structure-css&#8217;, get_template_directory_uri() . &#8216;\/jquery-ui.structure.css&#8217; );<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> wp_enqueue_style( &#8216;style&#8217;, get_stylesheet_uri() );<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\">\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> \/\/ scripts<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> wp_register_script( &#8216;custom.js&#8217;, get_template_directory_uri() . &#8216;\/js\/custom.js&#8217;, array(&#8216;jquery&#8217;, &#8216;jquery-ui-selectmenu&#8217;), &#8216;1.0.0&#8217;, true );<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i> wp_enqueue_script(&#8216;custom.js&#8217;);<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i>}<\/i>\u00a0<\/span><br \/>\n<span style=\"color: #000080;\"><i>add_action( &#8216;wp_enqueue_scripts&#8217;, &#8216;my_add_theme_scripts&#8217; );<\/i><\/span><\/p>\n<h3><b style=\"font-style: inherit;\"><span data-contrast=\"none\">2. Adding JavaScript Anywhere on Your WordPress Site withthe Plugin WPCode<\/span><\/b><\/h3>\n<p><span data-contrast=\"auto\">In some cases, for a plugin or tool to function properly, you will need to copy and paste a snippet of JavaScript code into your website. These scripts typically reside in the WordPress blog&#8217;s header or footer, loading the code with each page view.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">For instance, in order for Google Analytics to keep track of visitors on your website, you need to manually insert a code to run on each and every page of your website. You can manually add the code to your header.php and footer.php files, but when you update or change your theme, these changes will be overwritten. Because of this, we recommend adding JavaScript to your entire WordPress website with the help of <\/span><a href=\"https:\/\/wpcode.com\/\" target=\"_blank\" rel=\"nofollow noopener\"><span data-contrast=\"none\">WPCode.<\/span><\/a><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">It\u2019s a powerful WordPress plugin that simplifies adding custom code to any area of your website. Best part: it\u2019s free!<\/span><\/p>\n<h3><b style=\"font-style: inherit;\"><span data-contrast=\"none\">3. Adding JavaScript to HTML<\/span><\/b><\/h3>\n<p><span data-contrast=\"auto\">There are two methods for integrating JavaScript into HTML. One\u00a0is by adding it directly to the file and the other is through a separate file. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h4><b><span data-contrast=\"auto\">Adding JavaScript Directly to a File<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h4>\n<p><span data-contrast=\"auto\">Direct addition of JavaScript to HTML is the first option. You can accomplish this by employing the <\/span><i><span data-contrast=\"auto\">&lt;script&gt; &lt;\/script&gt;<\/span><\/i><span data-contrast=\"auto\"> tag, which ought to cover all of your JS code. You can add JS code between the <\/span><i><span data-contrast=\"auto\">&lt;head&gt;<\/span><\/i><span data-contrast=\"auto\"> and <\/span><i><span data-contrast=\"auto\">&lt;body&gt;<\/span><\/i><span data-contrast=\"auto\"> tags. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">The loading will differ depending on where you add the JavaScript code to your HTML file. It is best to place it in the <\/span><i><span data-contrast=\"auto\">&lt;head&gt;<\/span><\/i><span data-contrast=\"auto\"> section so that it remains distinct from the HTML file&#8217;s actual content. However, if you put it in the <\/span><i><span data-contrast=\"auto\">&lt;body&gt;<\/span><\/i><span data-contrast=\"auto\">,<\/span><span data-contrast=\"auto\"> the actual website content will load faster and the JavaScript will only be parsed after that.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Let\u2019s say you want to\u00a0add a JavaScript that\u2019s supposed to show the current time, here\u2019s how it will look like:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;!DOCTYPE html&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;html lang=&#8221;en-US&#8221;&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;head&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;meta charset=&#8221;UTF-8&#8243;&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1&#8243;&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;script&gt;JAVASCRIPT IS USUALLY PLACED HERE&lt;\/script&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;title&gt;Time right now is: &lt;\/title&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;\/head&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;body&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;script&gt;JAVASCRIPT CAN ALSO GO HERE&lt;\/script&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;\/body&gt;<\/i>\u00a0<\/span><\/p>\n<p><span style=\"color: #000080;\"><i>&lt;\/html&gt;<\/i>\u00a0<\/span><\/p>\n<h4><b><span data-contrast=\"auto\">Adding JavaScript on a Separate File<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h4>\n<p><span data-contrast=\"auto\">Sometimes it doesn&#8217;t seem like the best way to directly add JavaScript to HTML. Most of the time, it&#8217;s best to keep JavaScript code in separate files because some JS scripts need to be used on multiple pages. Because of this, external file importing is another way of adding JavaScript to HTML. Here are a few advantages of putting JS code on separate files:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"7\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559683&quot;:0,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\"><span data-contrast=\"auto\">The design principle of concern separation is met when HTML and JavaScript code are separated, making everything significantly more reusable and sustainable.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"7\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559683&quot;:0,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"10\" data-aria-level=\"1\"><span data-contrast=\"auto\">Maintenance and readability of the code are greatly simplified.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"7\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559683&quot;:0,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"11\" data-aria-level=\"1\"><span data-contrast=\"auto\">By reducing the amount of time it takes for pages to load, cached JavaScript files improve website performance as a whole.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/li>\n<\/ul>\n<h3><b><span data-contrast=\"none\">Why should I Insert JavaScripts in WordPress and HTML? <\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">WordPress is the simplest and most widely used platform for developing a blog, web application, or website. It allows the use of plugins to modify websites and even add custom functions.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">When you want to add an element, like audio or video players, to your WordPress page, that would usually slow down your server when deployed. Hence, adding JavaScript is helpful. Additionally, if you use a lot of third-party software, you may need to insert a script in HTML for them to work smoothly.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Since JavaScript is composed of an HTML page, it really depends on the client&#8217;s web browser to choose how to manage it. Although JavaScript can be used on the server side, the client-side implementation is where its true power lies.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Event-based actions are one example of additional JavaScript implementation opportunities. For example, when you need your website to react to user actions like mouse clicks or window resizing.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<h2><b><span data-contrast=\"none\">Maximise WordPress Website Opportunities with Javascript!<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:259}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"auto\">At first, using JavaScript to make individual modifications to your WordPress website may appear intimidating. However, you will have complete control over your themes and integrations once you understand how to successfully implement this essential programming language.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">As the owner or developer of a WordPress website, high-quality resources make all the difference in your work. So, aside from learning this essential programming language, ensure that you use a reliable <\/span><a href=\"https:\/\/www.crazydomains.com.au\/wordpress-hosting\/?utm_source=blog&amp;utm_medium=CD_ContentHub&amp;utm_campaign=add-javascript-to-wordpress-websites\" target=\"_blank\" rel=\"nofollow noopener\"><span data-contrast=\"none\">WordPress hosting<\/span><\/a><span data-contrast=\"auto\"> service for your website.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript is utilised in a wide range of applications, including game development, web application development, and more. It is also a well-established front-end language that continues to grow and provide flexibility to website functions \u2013 especially WordPress. If you have a plugin for a slider, social media links, or responsive navigation menu on your website, [&hellip;]<\/p>\n","protected":false},"author":1268,"featured_media":50936,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5644,1226],"tags":[7289,7292,1459,6193],"coauthors":[6249],"class_list":["post-50982","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","category-website","tag-html","tag-javascript","tag-website-tips","tag-wordpress-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>3 Simple Ways to Add JavaScript in WordPress<\/title>\n<meta name=\"description\" content=\"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.\" \/>\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.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"3 Simple Ways to Add JavaScript in WordPress\" \/>\n<meta property=\"og:description\" content=\"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\" \/>\n<meta property=\"og:site_name\" content=\"Crazy Domains Learn\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-22T04:01:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-22T04:27:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.crazydomains.com\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"768\" \/>\n\t<meta property=\"og:image:height\" content=\"385\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Harlan Tantog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Harlan Tantog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\"},\"author\":{\"name\":\"Harlan Tantog\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/31501ae4d5701e9ba834ce356b3e9d66\"},\"headline\":\"How to Insert JavaScript in WordPress Websites\",\"datePublished\":\"2022-12-22T04:01:09+00:00\",\"dateModified\":\"2022-12-22T04:27:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\"},\"wordCount\":1137,\"publisher\":{\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png\",\"keywords\":[\"HTML\",\"JavaScript\",\"Website Tips\",\"WordPress website\"],\"articleSection\":[\"General\",\"Website Archives - Crazy Domains Learn\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\",\"url\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\",\"name\":\"3 Simple Ways to Add JavaScript in WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png\",\"datePublished\":\"2022-12-22T04:01:09+00:00\",\"dateModified\":\"2022-12-22T04:27:58+00:00\",\"description\":\"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage\",\"url\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png\",\"contentUrl\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png\",\"width\":768,\"height\":385,\"caption\":\"Learn how to insert JavaScript in WordPress.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.crazydomains.com.au\/learn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Insert JavaScript in WordPress Websites\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#website\",\"url\":\"https:\/\/www.crazydomains.com\/learn\/\",\"name\":\"Crazy Domains Learn\",\"description\":\"Resources to help you excel online\",\"publisher\":{\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.crazydomains.com\/learn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#organization\",\"name\":\"Crazy Domains Learn\",\"url\":\"https:\/\/www.crazydomains.com\/learn\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2021\/02\/learn-dash-blue-logo-2.svg\",\"contentUrl\":\"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2021\/02\/learn-dash-blue-logo-2.svg\",\"width\":147,\"height\":43,\"caption\":\"Crazy Domains Learn\"},\"image\":{\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/31501ae4d5701e9ba834ce356b3e9d66\",\"name\":\"Harlan Tantog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/image\/f88f745967d11a10235aac51e7f541f1\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a92c269f80cb5dd451f07d60278eb887?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a92c269f80cb5dd451f07d60278eb887?s=96&d=mm&r=g\",\"caption\":\"Harlan Tantog\"},\"url\":\"https:\/\/www.crazydomains.com\/learn\/author\/harlan-t\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"3 Simple Ways to Add JavaScript in WordPress","description":"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.","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.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/","og_locale":"en_US","og_type":"article","og_title":"3 Simple Ways to Add JavaScript in WordPress","og_description":"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.","og_url":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/","og_site_name":"Crazy Domains Learn","article_published_time":"2022-12-22T04:01:09+00:00","article_modified_time":"2022-12-22T04:27:58+00:00","og_image":[{"width":768,"height":385,"url":"https:\/\/www.crazydomains.com\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png","type":"image\/png"}],"author":"Harlan Tantog","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Harlan Tantog","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#article","isPartOf":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/"},"author":{"name":"Harlan Tantog","@id":"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/31501ae4d5701e9ba834ce356b3e9d66"},"headline":"How to Insert JavaScript in WordPress Websites","datePublished":"2022-12-22T04:01:09+00:00","dateModified":"2022-12-22T04:27:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/"},"wordCount":1137,"publisher":{"@id":"https:\/\/www.crazydomains.com\/learn\/#organization"},"image":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage"},"thumbnailUrl":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png","keywords":["HTML","JavaScript","Website Tips","WordPress website"],"articleSection":["General","Website Archives - Crazy Domains Learn"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/","url":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/","name":"3 Simple Ways to Add JavaScript in WordPress","isPartOf":{"@id":"https:\/\/www.crazydomains.com\/learn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage"},"image":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage"},"thumbnailUrl":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png","datePublished":"2022-12-22T04:01:09+00:00","dateModified":"2022-12-22T04:27:58+00:00","description":"JavaScript lets you add custom functions to your website. Learn how to insert JavaScript in WordPress in this article.","breadcrumb":{"@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#primaryimage","url":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png","contentUrl":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2022\/12\/768x385-6.png","width":768,"height":385,"caption":"Learn how to insert JavaScript in WordPress."},{"@type":"BreadcrumbList","@id":"https:\/\/www.crazydomains.com.au\/learn\/add-javascript-to-wordpress-websites\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.crazydomains.com.au\/learn\/"},{"@type":"ListItem","position":2,"name":"How to Insert JavaScript in WordPress Websites"}]},{"@type":"WebSite","@id":"https:\/\/www.crazydomains.com\/learn\/#website","url":"https:\/\/www.crazydomains.com\/learn\/","name":"Crazy Domains Learn","description":"Resources to help you excel online","publisher":{"@id":"https:\/\/www.crazydomains.com\/learn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.crazydomains.com\/learn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.crazydomains.com\/learn\/#organization","name":"Crazy Domains Learn","url":"https:\/\/www.crazydomains.com\/learn\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.crazydomains.com\/learn\/#\/schema\/logo\/image\/","url":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2021\/02\/learn-dash-blue-logo-2.svg","contentUrl":"https:\/\/www.crazydomains.com.au\/learn\/wp-content\/uploads\/2021\/02\/learn-dash-blue-logo-2.svg","width":147,"height":43,"caption":"Crazy Domains Learn"},"image":{"@id":"https:\/\/www.crazydomains.com\/learn\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/31501ae4d5701e9ba834ce356b3e9d66","name":"Harlan Tantog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.crazydomains.com\/learn\/#\/schema\/person\/image\/f88f745967d11a10235aac51e7f541f1","url":"https:\/\/secure.gravatar.com\/avatar\/a92c269f80cb5dd451f07d60278eb887?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a92c269f80cb5dd451f07d60278eb887?s=96&d=mm&r=g","caption":"Harlan Tantog"},"url":"https:\/\/www.crazydomains.com\/learn\/author\/harlan-t\/"}]}},"lang":"au","translations":{"au":50982,"us":50931,"uk":50983,"zh":50984,"in":50985,"id":50986,"my":50987,"ph":50988,"sg":50989,"ae":51020,"nz":51022},"pll_sync_post":{"us":true,"au":true,"uk":true,"zh":true,"in":true,"id":true,"my":true,"ph":true,"sg":true,"ae":true,"nz":true},"_links":{"self":[{"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/posts\/50982"}],"collection":[{"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/users\/1268"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/comments?post=50982"}],"version-history":[{"count":0,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/posts\/50982\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/media\/50936"}],"wp:attachment":[{"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/media?parent=50982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/categories?post=50982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/tags?post=50982"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.crazydomains.com.au\/learn\/wp-json\/wp\/v2\/coauthors?post=50982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}