Follow us on

How to Easily Add JavaScript in WordPress Website

How to Easily Add JavaScript in WordPress Website

Do you want to add JavaScript in your WordPress Website? Most of the times you may need to add JavaScript into your whole WordPress site or sometimes in a specific pages or posts. Well you can do all these things by just using a simple plugins. So You don’t need to play with Theme files. In this article, we will show you how to easily add JavaScript in WordPress Website

JavaScript Coding

What is JavaScript?

JavaScript is a programming language which runs on User’s Browser. This client-side programming allows developers to do a lot of cool things without slowing down your website.

If you want to use a feature which is based JavaScript then it becomes harder to use it because WordPress doesn’t allow to use any programming language by default

Now, if you add a JavaScript code snippet to a WordPress post or page, then it will be deleted by WordPress when you try to save it or publish it.

So today i’m here to tell how you can easily add JavaScript Code in your whole WordPress site or specifically in post or page. So let’s begin

1) How to add JavaScript Code to whole website

If you want to add a feature or a Third-Party Tool in your website then those JavaScript Code usually goes to header section that between <head></head> or maybe sometimes in body section. All these things can be fulfilled by using a simple plugin called Insert Headers and Footers.

Insert Headers and Footers is a simple plugin that lets you insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer. No need to edit your theme files!

So go ahead and install this plugin now. Upon activation, you need to visit Settings » Insert Headers and Footers page. You will see three boxes, one for the header, second one for body and the other one for the footer section.

Now Paste your JavaScript code in one of these boxes that you want to. After that Click on Save Button.

Insert Headers and Footers will automatically apply the code to all the pages of your website.

2. How to add JavaScript Code to Specific Post or Page

This method allows you to add JavaScript code to any Specific pages or posts of your WordPress website.

In order to do that, You need to first install a Plugin called Code Embed and then activate it.

Upon activation, you need to edit the post or page where you want to add the javascript. On the post edit page, click on the ‘Screen Options‘ button and check the ‘Custom Fields’ option.

Now scroll down and you will see the ‘Custom Fields’ metabox where you need to click on the ‘Enter new’ link.

The custom field name and value fields will now appear.

You need to provide a name for the custom field with a CODE prefix (for example, CODEmyjscode) and then paste the javascript code in the value field.

Don’t forget to click on the ‘Add Custom Field’ button to save your custom field.

Now you can use this custom field to embed the JavaScript code anywhere in this post or page. Simply add this embed code anywhere in your post content.


You can now save your post or page and view your site. You will be able to see the javascript code by using the Inspect tool or by viewing the page source.

I Hope this article is helpful for you, If yes then consider sharing it with your friends and families. Till then i’ll see you in next helpful article.


​Hey, I’m Venkat Lohith Dasari AKA Denny. A Full Time Blogger , YouTuber, Affiliate Marketer and Founder of and YouTube Channel. A guy from the crowded streets of India who loves to watch best Movies and Triller TV Shows! I watch Beyhadh!

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *

Share via
Copy link
Powered by Social Snap