[4.0] WebAsset support for inline assets#27756
Conversation
|
No and Yes. if you specify the position and dependency, then it rendered at requested position: Will produce: |
|
@Fedik FWIW since this is a brand new functionality please drop this: |
|
If you need "this specific inline CSS", to be loaded after "that specific CSS file", you explicitly set dependency and position of your inline CSS (before/after). Instead of playing dice. However there should not be a big problem to change it (it just about how to render). |
|
Le documentation please. This seems pretty b/c and incorporates the last parts of the JDocument API. I'm happy with this |
|
@wilsonge please review https://docs.joomla.org/J4.x:Web_Assets |
|
btw, what do you think do we need to move addScriptOptions() to assetManager (proxy them) or leave it for j5? |
|
I'd leave them out totally I think? Script options aren't really related to the assets in my view. I mean they do support the asset. But they don't depend on the asset existing. Unless you're planning on having proper error page generated by php whenever a script option doesn't exist for an asset or something? |
But also the script options makes no sense without scripts 😉
No, nothing like that, the options is not required anyway, the script should have fallback to some default value, as usual. okay, I leave it as is for now, nothing really important |
|
@Fedik quick question: are the assets using their own version or you're still using the global mediaVersion from the document? |
True but my gut is about them not being required like you say. I mean I'm not totally convinced by my own arguments 🤷♂ |
if asset have defined |
This is for make the thing complete
Summary of Changes
The patch add support of inline content to asset manager with support of optional
before/afterpositions (discussion here #25309). And improves script/style rendering a bit.And a new
headachesurprise for @wilsonge 😃Also the script options rendered as inline asset with position "before" a core asset.
New methods of asset manager:
addInlineStyle,addInlineScript.Simple example:
Example with support of positioning:
Testing Instructions
Apply patch, and try play with new methods.
Example add this to index.php of Atum template:
Then check the source code of the page, and make sure the content are rendered and have a requested positions.
Merging the patch, notes
In theory the patch can be merged as is now, it does not introduce b.c.
However, we can pretty safely proxy existing
$doc->addScriptDeclaration()/$doc->addStyleDeclaration()to$doc->assetmanager->addInline(). In this case$doc->_style/$doc->_scriptwill stay empty (ignored), wich introduce a little b.c.But we already made b.c. changes for these properties (to support array instead of string #25357), I think it acceptable.
What do you think @wilsonge @mbabker . If you agree I will do these changes, otherwise I leave as is.
Documentation Changes Required
yeap
for reference #25309 #23463 #22435