JS loading, but not working and then working when put the code in console

The JS is loading, but not working.

However, if we put the same JS code in the console than it works.

Hi @codeispoetry, if you’re referring to faq.js then it’s throwing an error because you forgot to include jQuery first; running that code from the console will yield the same result though.

Then it works.

No it does not.


(Although to correct myself, it actually is another error since the $ is also command line API.)

1 Like

sir, how to fix these issues?

Load jQuery first, or remove the jQuery code (which is only the $(document).ready() wrapper which you don’t need if you just put your script to the end of the body – see the $in_footer parameter here).

Already deleted looks like shared hosting has some cache issue.

In this case just increase the $ver value in wp_enqueue_script() (same link from above).

Now if you put script in console than it works.

The script is still getting included in the head, you have to put it before the closing </body> tag.

1 Like

wp_enqueue_script() expects up to 5 arguments but you’re passing 6; please check the documentation again for the correct position of the $in_footer flag.

1 Like

Problems were in the servers. they were not updating code immediately. some cache effect that last for 30 minutes in case of css and JS.

Cached or not, the arguments you’re passing to wp_register_script() don’t match its type signature – you have to remove that empty string after the dependencies array.

1 Like

Yes, I fixed that sir.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.