Hey guys,
I have CSS and JS files in my plugin.
How can I position the Standard Page JavaScripts (bodyScripts - javascripts.site) after the JavaScripts from my plugin.
I have tried it with the following:
javascripts.site = Neos.Fusion:Template {
@position = 'end 99'
}
and my custom thing:
fundamentalFooterJs = Neos.Fusion:Tag {
@position = 'end 98'
tagName = 'script'
attributes {
type = 'text/javascript'
src = Neos.Fusion:ResourceUri {
path = 'resource://Fundamental.Site/Public/JavaScript/app.js'
}
}
}
… but the Pages JavaScript always placed above my Plugins JavaScript.
Can someone help me? Thx!
dfeyer
(Dominique Feyer)
July 11, 2017, 12:14pm
2
javascripts.myPlugin = Neos.Fusion:Tag {
@position = 'before site'
tagName = 'script'
attributes {
type = 'text/javascript'
src = Neos.Fusion:ResourceUri {
path = 'resource://Fundamental.Site/Public/JavaScript/app.js'
}
}
}
This should work, try to avoid numerical position (before 43, after 12, …) it can be hard to maintain.
dfeyer
(Dominique Feyer)
July 11, 2017, 12:15pm
3
And if you need a bit more compact syntax and bit more feature (like HTTP cache busting):
So with the script package (http cache busting is enabled by default):
javascripts.myPlugin = Ttree.Script:Resource {
@position = 'before site'
uri = 'resource://Fundamental.Site/Public/JavaScript/app.js'
}
Hi Dominique!
Thank you for answer! For my own Neos Fusion Tags it works, but not for the Sites “Standard” like
javascripts.site = Neos.Fusion:Template
dfeyer
(Dominique Feyer)
July 11, 2017, 12:43pm
5
The @position is independant from the fusion prototype, basically the javascripts path (in head and body) use a Neos.Fusion:Array and this one support the @position , maybe you can post a more complete code sample ?
Okay, thank you.
This is my Site Page.html
<f:section name="body">
{content.main -> f:format.raw()}
</f:section>
<f:section name="bodyScripts">
<script src="{f:uri.resource(path: 'JavaScript/main.js', package: 'Neos3Dev.Site')}"></script>
</f:section>
And this is my custom JS:
fundamentalFooterJs = Neos.Fusion:Tag {
@position = 'after body'
tagName = 'script'
attributes {
type = 'text/javascript'
src = Neos.Fusion:ResourceUri {
path = 'resource://Fundamental.Site/Public/JavaScript/app.js'
}
}
}
But the <f:section name="bodyScripts">
is placed before the fundamentalFooterJs.
dfeyer
(Dominique Feyer)
July 11, 2017, 1:25pm
7
It’s an invalid HTML to have a script tag after the closing body should be in the body tag
body.javascripts.myPlugin = Neos.Fusion:Tag {
@position = 'end'
tagName = 'script'
attributes {
type = 'text/javascript'
src = Neos.Fusion:ResourceUri {
path = 'resource://Fundamental.Site/Public/JavaScript/app.js'
}
}
}
But the “section body” is not the bodytag. My “real” bodytag wraps section body and bodyscripts so it’s valid enough. Sorry, I have not copied the whole syntax.
I would like to place my own JS behind the section body. And the “Default” JS from the SitePackage after the bodyScripts Section.