Project

General

Profile

Actions

Feature #91951

open

FLUID assets

Added by Christian Hackl over 4 years ago. Updated 3 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2020-08-07
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
fluid assets
Complexity:
Sprint Focus:

Description

Hello,
can we get a "order" attribute of the assets viewhelpers?

for example, I have 2 times the f:asset.script viewhelper in my template. The first one should be an inline script and the second one is an external file.
TYPO3 renders the external file before the inline one...

<f:asset.script identifier="first" priority="true">alert("my inline script");</f:asset.script>
<f:asset.script identifier="functions" src="EXT:my_ext/Resources/Public/JavaScript/functions.min.js" priority="true" />

Maybe you can change the "identifier" to get a sort order.

thank you!

Actions #1

Updated by Riccardo De Contardi about 4 years ago

  • Category set to Fluid
Actions #2

Updated by Benni Mack about 3 years ago

  • Status changed from New to Needs Feedback

Hello Christian,

do you want to get the inline code BEFORE the included external file?

Actions #3

Updated by Christian Hackl about 3 years ago

Benni Mack wrote in #note-2:

Hello Christian,

do you want to get the inline code BEFORE the included external file?

for this example yes, but not only for inline-code.

Actions #4

Updated by Garvin Hicking 3 months ago

Wouldn't maybe using "defer" for the external script solve this? Then the inline javascript would get parsed first.

Personally I don't think adding an order to javascripts is a solution that should be recommended (even though I understand the need).

Nowadays I would rather like to recommend building isolated javascript files that have no influence/dependency on each other. If they do, they should IMO be bundled, possibly by independent tooling (webpack, vite, etc.). What do you think?

Actions #5

Updated by Christian Hackl 3 months ago

@Garvin Hicking
hmm, I'm a fan of simple things, which doesn't exactly include all those package managers like webpack. :)
It would also be easier for beginners to understand, I would think ;)
Besides, I think it's possible in TypoScript, so why not in FLUID?
I don't know exactly how the FLUID is assembled at this point, if all the scripts / src'es are in an array before the HTML rendering, it shouldn't be a big problem to run a ksort() via the “identifier”. Maybe an additional TypoScript option / flag to switch the sorting on and off?

Actions #6

Updated by Garvin Hicking 3 months ago

Fair enough :)

I haven't checked in on how TS vs. fluid handles prioritization. Since it hasn't gained traction to get addressed in 4 years I'm not sure we will find someone to look into it, so I just wanted to offer an alternative other than "waiting for godot". ;)

Actions

Also available in: Atom PDF