Skip to main content
Where should JavaScript (JS) code be added in Divi?

This tutorial will guide you where you can add JS and jQuery codes in Divi theme

Updated over a week ago

There are primarily two locations within the Divi theme where you have the option to insert JavaScript (JS), jQuery, or third-party tracker codes. Depending on your specific needs, you can add these codes in the following areas:

1. If you wish for the code to execute across your entire website

If you want to add to run on every page of your website, the best place to add your jQuery or JavaScript (JS) code would be in Divi > Theme Options > Integration tab > head or body area:

Based on your code, you have the flexibility to include it either in the head or body section.

This section can be utilized to add Google or other third-party tracking codes as per the guidelines they provide, which may specify placement within either the head or body of your pages.

2. If you wish the code to execute on a specific page/post only

  • Option 1: If you want to add JavaScript (JS) code in the body area of a specific page only

    If you are using Divi Builder on the page and need to add a Javascript (JS) or jQuery code only to that page body content area, you can use the native Divi Code module in Divi Builder and place the code in the Code module:


  • Option 2: If you want to add the JavaScript (JS) code in the head of a specific page only

    In Divi, it's not possible to natively insert scripts exclusively within the head tag of a specific page. To achieve this functionality, you'll need to install a third-party plugin, such as the following one:

    Once the plugin is installed, you'll discover a range of features for adding JavaScript (JS) code and applying it to particular pages or posts only.

    It's recommended to review the plugin's description and screenshots to gain a clear understanding of its functionality.

Did this answer your question?