1

I am trying to upgrade my Joomla 3 website to Joomla 4. One of the issues I am facing is that none of the jQuery code in my template's index.php file is working. Does jQuery not get loaded automatically anymore? I never had to do anything special to get it working in Joomla 3.

1 Answer 1

3

Yes, for the most part J4 uses vanilla JavaScript and dependencies like jQuery should be loaded only when needed. If it's needed by your template's script files, you can add it as dependency in your joomla.asset.json file:

{
  "name": "template.your-template",
  "type": "script",
  "uri": "template.js",
  "dependencies": [
    "jquery"
  ]
}

Or you can manually enable it in template layouts:

$this->getWebAssetManager()->useAsset('script', 'jquery');

If jQuery is needed only in specific component view or module layouts, that's where you should be loading them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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