Skip to main content

JavaScript

The JavaScript editor in the Easy Custom Code Customizer panel lets you add custom JavaScript to your site without editing theme files. Your script is compiled into a JS file and loaded on every frontend page.

Opening the Editor​

  1. Navigate to Easy Custom Code → Open Customizer in the admin sidebar
  2. In the Customizer panel, find the JavaScript code editor
  3. Type or paste your JavaScript code

The <script> tag is not needed — enter only the JavaScript code itself.

Writing Custom JavaScript​

// Change the text color of all paragraphs on page load
document.addEventListener('DOMContentLoaded', function() {
var paragraphs = document.querySelectorAll('p');
paragraphs.forEach(function(p) {
p.style.color = '#333333';
});
});

The live preview on the right side of the Customizer reflects your changes in real time, though some scripts (e.g. those that depend on external services) may only take full effect on the published site.

JavaScript Position​

By default, your custom JavaScript file is loaded in the footer (before the closing </body> tag), which is the recommended placement for most scripts as it does not block page rendering.

If you need your script to load in the <head> — for example for tracking pixels, consent management scripts, or verification tags — change this setting from Settings → Easy Custom Code → JavaScript Position. See the Settings page for details.

caution

Loading JavaScript in the <head> can delay page rendering because the browser must parse and execute the script before continuing. Only use the head position when required by the script's purpose.

External Scripts​

In addition to your custom JS, you can load external JavaScript libraries from a URL (e.g. a CDN-hosted library). Click the Add External Scripts button below the JavaScript editor to open the modal.

External Scripts Modal​

To add an external script:

  1. Click + add another resource
  2. Enter the full URL of the script (e.g. https://cdn.jsdelivr.net/npm/some-library@1.0.0/dist/lib.min.js)
  3. Click Apply Changes to close the modal

To remove a script:

  • Click the × button next to the URL entry

To reorder scripts:

  • Use the ↑ and ↓ arrow buttons. Scripts are loaded in the order they appear in the list.

External scripts are loaded in the same position (head or footer) as your custom JavaScript, as configured in Settings → Easy Custom Code.

How the Compiled JS is Served​

When you click Publish in the Customizer, the plugin:

  1. Saves your custom JavaScript to wp-content/uploads/easy-custom-code/js/ with a timestamped filename (e.g. script_1716652800.js)
  2. Enqueues the file on the frontend via wp_enqueue_script

The timestamped filename ensures that caching plugins and CDNs serve the latest version after each publish.

Full-Screen Editor (Pro)​

Pro Feature

The full-screen editor is available in Easy Custom Code PRO. See PRO pricing.

Click the [Maximize editor] link below the JavaScript editor to expand it to a full-screen modal window, giving you more space to write and review longer scripts. Click Minimize to return to the Customizer.