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.

 
mnakalay replied on at Permalink Reply
mnakalay
That would be great but unfortunately, it is not, for now, possible using the asset manager.

You can, however, use the addHeaderItem() and addFooterItem() functions to add your script and stylesheet tags the way you want them.
Kiesel replied on at Permalink Reply
Thank you Mnakalay, at least I have clarity now.
JohntheFish replied on at Permalink Reply
JohntheFish
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?
mnakalay replied on at Permalink Best Answer Reply
mnakalay
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.
JohntheFish replied on at Permalink Reply
JohntheFish
Brilliant!
mnakalay replied on at Permalink Reply
mnakalay
Does it mean you're going to have a pull request with that feature soon John???? :)
JohntheFish replied on at Permalink Reply
JohntheFish
I bet if we raised this as an issue @mlocati will beat us both to it.
JohntheFish replied on at Permalink Reply
JohntheFish
mlocati replied on at Permalink Reply
mlocati
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
mnakalay replied on at Permalink Reply
mnakalay
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
mlocati replied on at Permalink Reply
mlocati
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!
mnakalay replied on at Permalink Reply
mnakalay
Really? Nothing else, really???!!!!!

Not even... COFFEE!!!!!!!!!!!
mlocati replied on at Permalink Reply
mlocati
....detoxification;)