RequireAsset with async or defer
Permalink
Hi
Is it possible now to load js scripts over requireAsset with an async or defer tag?
It would be great if we have another parameter when registering assets that allows us to put one of these tags on, which in turn would group it into it's own file.
So if we minify and combine 9 js files and 3 of them should be loaded with defer, that we get 2 js loads, one for the 6 files without defer, one for the other 3 with defer.
Is it possible now to load js scripts over requireAsset with an async or defer tag?
It would be great if we have another parameter when registering assets that allows us to put one of these tags on, which in turn would group it into it's own file.
So if we minify and combine 9 js files and 3 of them should be loaded with defer, that we get 2 js loads, one for the 6 files without defer, one for the other 3 with defer.
Thank you Mnakalay, at least I have clarity now.
If async functionality were to be added to the core asset management system, would it be more appropriate to specify it in the asset declaration?
Ideally, the asset registration function should really have a "attributes" parameter, probably as an array. That would be useful not only for attributes like defer and async but also if the need for a class name or an ID or any other attribute would arise, for JS interaction for instance.
Brilliant!
Does it mean you're going to have a pull request with that feature soon John???? :)
I bet if we raised this as an issue @mlocati will beat us both to it.
LOL!
Well, you may be right, but not in the near future: after a break of a couple of weeks, I'd need some days to catch up
Well, you may be right, but not in the near future: after a break of a couple of weeks, I'd need some days to catch up
Do you mean to say you took an actual break? A real no-concrete5-related work, no compulsive GitHub fiddling, no development of any kind break?
Are you ok :p
Are you ok :p
Yep! Two full weeks on the fantastic tiny beach of Faros Rooms in Livadia (google for it;) )
Relax, snorkeling, good food, some beers, a couple of hikes and nothing else!
Relax, snorkeling, good food, some beers, a couple of hikes and nothing else!
Really? Nothing else, really???!!!!!
Not even... COFFEE!!!!!!!!!!!
Not even... COFFEE!!!!!!!!!!!
....detoxification;)
You can, however, use the addHeaderItem() and addFooterItem() functions to add your script and stylesheet tags the way you want them.