Tell me please. How to load jQuery in Joomla 4 if it has not been loaded yet?

  • Your question is clear, but has been flagged by the system as being low-quality due to its length. Might you edit your question to include attempts that you've made and relevant online resources that are on-topic? I like to upvote questions, but my personal criteria requires that effort/research is demonstrated in the question. Commented Jan 13, 2022 at 19:53

2 Answers 2


You should be able to load it like so:


Else, if you're using Joomla's Web Asset Manager, then you can define it as a dependency in your JSON object:

  "name": "foobar",
  "type": "script",
  "uri": "com_mycomponent/script.min.js",
  "dependencies": [

Lodder answer is certainly useful, but not what I wanted to see. The correct loading of the embedded jquery looks like this.

use Joomla\CMS\Factory;

$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

This will work if jquery has not been loaded before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.