Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Make ScriptTagHelper work with defer and async script tags. #5168

Closed
NTaylorMullen opened this issue Aug 19, 2016 · 7 comments
Closed

Make ScriptTagHelper work with defer and async script tags. #5168

NTaylorMullen opened this issue Aug 19, 2016 · 7 comments
Labels

Comments

@NTaylorMullen
Copy link
Contributor

Script tags have the ability to provide an async/defer attribute to modify the timing on when they're loaded into the page. This behavior breaks our expectations for our ScriptTagHelper and you end up with both the base script and the fallback script loaded.

We should design a route for our script load detection logic to work when these two parameters are present.

@danroth27 danroth27 added bug and removed bug labels Aug 22, 2016
@Eilon
Copy link
Member

Eilon commented Nov 28, 2016

@NTaylorMullen @DamianEdwards any chance of us actually doing something here? Is the answer that if you need to do more advanced <script> tags then just use a proper script loader?

@NTaylorMullen
Copy link
Contributor Author

We could potentially do something here but the "right" thing would have to be investigated. That ranges from collecting script tags on a page and then collectively rendering them or changing our script injection logic to utilize the DOM. Both these solutions become possible once defer/async come into the picture. Doing this also depends on if we want to invest the time because your latter suggestion is also accurate.

@Eilon
Copy link
Member

Eilon commented Nov 28, 2016

Yeah I have a feeling that if our script tag helper has to render like 10-15 lines of complex JS code then this isn't the right avenue...

@DamianEdwards
Copy link
Member

What if we only do these things if the defer or async attributes are set? As in, we leave the current behavior as is, but if we see defer or async we collect up the scripts and load them at the end of the page (via a new <body> Tag Helper or similar), using the DOM. We could even make the logic that does this pluggable so folks can easily plug in something that emits different client-side logic for various script loaders.

@Eilon
Copy link
Member

Eilon commented Dec 27, 2016

Is this even worth it then? Just don't use our tag helpers? We could certainly build an extensibility system but it seems easier to just write the code yourself... or write your own tag helpers... ?

@DamianEdwards
Copy link
Member

Yeah it might be better to just tackle the addition of <head>, <body>, etc. Tag Helpers such that it's easy for people to create whatever script/asset collection helpers they want.

@Eilon
Copy link
Member

Eilon commented Mar 4, 2017

Given our plans in #5728 to improve the experience of adding scripts in general, I'm closing this issue.

@Eilon Eilon closed this as completed Mar 4, 2017
@Eilon Eilon added the wontfix label Mar 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants