-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Flexible placement of plugin assets (files & inline styles/code) #876
Comments
why not just move the This way all the default stuff will load at the bottom, and you can put specific ones you want at the top in that Regarding jQuery, you could manually add it to your |
Actually there's no easy way currently to get and set the assets manually. I'm going to add some getter/setters. |
…d allow full control of manipulating assets via plugins. #876
Ok that should let you do pretty much anything from a plugin or theme event. If you know the asset path, you can manipulate it.. either remove it, and then add a custom one, or you could just get the whole array, find the one you want, modify it, including changing group, and then setting the array back on the Assets manager. |
By moving |
Has this been solved? If yes: could you let me know how you did it? |
In order to get the fastest possible "Time to render" i'm doing critical path optimization. So far i had some pleasant surprises with using grouping, prioritizing, etc to sort the load order. However, there is one major problem, that i can't seem to overcome.
In
base.html.twig
, next to the assets i add myself, Grav automatically adds JS (and CSS) files from the activated plugins which ALWAYS are placed within{{ assets.css() }}
(or .js). As far as i know, there is no way to change that. This is really problematic in regards to optimization.In my case, i have a separate critical path CSS file, which i want to inline in the header, using the Custom CSS Plugin. Since this file contains all necessary styles for content "above the fold", i want to relocate ALL OTHER CSS to the bottom, just before the
</body>
.Unfortunately, this is not possible because the inline style as well as all the plugin styles (in my case Featherlight, Lightslider) get grouped automatically in
{{ assets.css() }}
and appear in the same place in the DOM.Now, this is very similar with JS-Assets:
I tried to completely relocate my JS from the
<head>
and put it just before the</body>
. Unfortunately the LightSlider-Plugin is constructed in a way, that it contains inline JS code inside a twig-template. And because this JS code needs jQuery to run, i need to call jQuery in the<head>
, making critical path optimization effectively impossible.I really think that there is huge potential for optimization here, to make grav as fast as possible, especially on mobile, where it really counts. I'd love to hear your feedback on this...
The text was updated successfully, but these errors were encountered: