ASSET-ADDSCRIPT-DECLARATION-001

$doc->addScriptDeclaration()

addScriptDeclaration / addStyleDeclaration

Declarations still work on Document but they skip asset ordering. WAM inline APIs are the Joomla 4+ path.

$doc->addScriptDeclaration()WebAssetManager addInlineScript / addInlineStyle

Dies at Joomla 4 → 5J3: Works nativelyJ4: Deprecated — do not shipJ6: Deprecated — do not shipBC plugin: not applicablePatch possible — review itJavaScript

Symptoms people search

inline js before jquery · addScriptDeclaration

Replace this code

Swap $doc->addScriptDeclaration() for WebAssetManager addInlineScript / addInlineStyle.

Joomla 3

Remove or stop calling this

$doc->addScriptDeclaration('alert(1);');
$doc->addStyleDeclaration('h1{color:red}');

Joomla 4 / 6

Use this instead

$wa->addInlineScript('alert(1);');
$wa->addInlineStyle('h1{color:red}');

How to fix it

  1. 1Move inline JS/CSS to WAM.
  2. 2Prefer a file in joomla.asset.json for anything reused.

Also known as

addScriptDeclaration · addStyleDeclaration · addInlineScript

Related issues

Get in touch

Have a project in mind? Let's talk about it.

Tell us what you're building. Whether it's a new site, an online store, a mobile app, or something that needs AI under the hood, we'll get back to you within a business day.

Free consultation
No commitment, no pressure
Reply within 24 hours
Usually much faster

Prefer a direct conversation?

Request a project quote

Tell us about your project

Fill out the quick form and we'll reach out.