WordPress Theme Javascript Not Working (5 Quick Solutions For Non-Coders)

WordPress Theme Javascript Not Working

[ctoc title=”Table of contents” type=”ol” items=”WordPress theme Javascript not working,Why is Javascript not working in WordPress?,What are the solutions?,Conclusion”]

Is your WordPress theme’s embedded javascript not working?

Whether you are using a free or premium or custom theme, Javascript is essential for the theme to function.

For example, the header of your website may not be responsive.

Or, your forms may not be working correctly.

This indicates that you are facing a WordPress theme Javascript not working issue.

If you are not a coder, these issues can be very frustrating.

Before contacting customer support for help you can try some steps yourself first.

So, let’s see what we, as non-coders can do to fix the issue ourselves.

WordPress theme Javascript not working

The reason for WordPress theme Javascript not working may be because of wrong codes or minification in the cache plugin or Javascript being disabled in the browser. Try enabling Javascript in the browser or deactivating all plugins, or adding the Javascript through a plugin or a child theme.

Why is Javascript not working in WordPress?

The most common reason for Javascript not working is a coding issue such as not using wp-enqueue-script, not using the wp-head function, not using wp-footer hooks, etc.

If you use a caching plugin and minification is turned on, that may have caused the issue too.

Or, it may be a simple issue such as Javascript not being not turned on in your browser.

What are the solutions?

Here is a step-by-step solution to the issue – 

1. Enable Javascript in the browser

First, check whether Javascript is enabled in your browser.

You can easily do this by following the instructions in this article.

2. Deactivate/Activate all plugins

If Javascript is already activated in your browser, check whether a plugin is causing the issue.

For this, first, deactivate all the plugins.

Now, check whether the Javascript is working.

If yes, activate each plugin one by one and see which one was causing the issue.

3. Use a child theme

If you were trying to add the Javascript directly to your theme, try adding it through a child theme.

If you do not have a child theme installed, you can easily create one for your theme.

Here are the steps – 

  • Log in to your site using FTP.
  • Go to wp-contents/themes folder.
  • Create a new folder in this format – yourtheme-child.
  • Upload the Javascript file in this folder. For example, the name of the file will be yourscript.js.
  • Create a new file in this folder called functions.php and add the following code:
<?php

add_action('wp_enqueue_scripts', 'enqueue_child_scripts');

function enqueue_child_scripts() { wp_enqueue_script('child-script', get_template_directory_uri() . '/script.js'); }

?>

Now, log in to WordPress and activate the child theme.

Then go to the front page of your site.

In Chrome, click the 3 dots on the top-right, go to More Tools and click Developer Tools.

Check whether the Javascript is loading under the Sources tab.

Please note that the page will not show the styles as we have not added a stylesheet for the child theme.

4. Use a plugin

How to add custom Javascript in WordPress child theme safely?

Well, in order to avoid conflicts between the Javascript and the functions in your theme, you can use a WordPress plugin that is made specifically for adding scripts.

I suggest using the Insert Headers and Footers plugin to insert the Javascript code into your site.

5. Coding Issue

If the above steps have not resolved the issue for you, then there may be an error in the code like wrong syntax or missing functions.

As such, you must contact the theme developer or the plugin as a last resort.

Conclusion

In order to resolve the issue of Javascript not working on your site you can –

  • Enable Javascript in your browser.
  • Deactivate all plugins.
  • Use a child theme to insert the Javascript.
  • Use the Insert Headers and Footers plugin to insert the Javascript.
  • Contact the theme or plugin developer, as a last resort.
Back To Top