Skip to content

[RFC] Inline assets #16

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

Open
grachevko opened this issue Nov 12, 2018 · 7 comments
Open

[RFC] Inline assets #16

grachevko opened this issue Nov 12, 2018 · 7 comments

Comments

@grachevko
Copy link

What about option to inline assets (CSS or JS) into twig?

@weaverryan
Copy link
Member

Yep, that’s interesting :). Can you tell me more about how you would use the feature? Online everything? Or choose if you want to inline on an entry-by-entry basis? Or by filesize?

@grachevko
Copy link
Author

I guess all of this. Somewhere need to inline everything, somewhere only js for page block but without vendor js.
By filesize, in my opinion, require delayed injection to prevent injection file in middle of page, If js will be greater than limit where this file are included, to include it in the bottom with others.

@PabloKowalczyk
Copy link

IMO inlining CSS can be very useful with "Critical CSS" technique - https://www.smashingmagazine.com/2015/08/understanding-critical-css/.

@seyfer
Copy link

seyfer commented Jan 10, 2019

Something like that required. We use inline assets with the custom extension now

<style type="text/css">{{ inline_asset(asset('css/some.css', 'widget'))|raw }}</style>
<script>{{ inline_asset(asset('js/some.js', 'widget'))|raw }}</script>

this still works with Webpack 4 encore if option .disableSingleRuntimeChunk() used.

@weaverryan
Copy link
Member

Btw, you could also iterator over the CSS or JS files via encore_entry_js_files() or encore_entry_css_files and then do your inline_asset() trick.

This feature is interesting - but I haven't researched it at all yet. I often look at what "native Webpack" does - an then try to stay as close to that as possible.

@carsonbot
Copy link
Collaborator

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@PabloKowalczyk
Copy link

@weaverryan are you open for PR with inline Twig helper?

@carsonbot carsonbot removed the Stalled label Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants