Loading assets in Packages breaks Sitemap
I'm using the on_start() method to add my .js to the AssetList and would expect it to be output somewhere within the header or footer on the site in order for me to use.:
I don't really understand how/ when exactly the Assets are included but what happens now is that the HTML Markup for the loading of the Script is added to some AJAX Requests as well. For example the one that fetches the Sitemap.
Witch leads to a parse Error because a stray script tag is added to the otherwise clean json Response.
The Question is: Is that behaviour by design and there is a better way to do this? Or is it an Issue worth mentioning on GitHub?
I think there should be some mechanism in place to avoid assets beeing output on AJAX Responses.
Or is there any reliable way to detect AJAX Requests within the on_start() method of my package? Then i could simply forgo registering the Asset in cases like that.
Of course Remo is right. register() itself doesn't cause the problem. It's more like registered Assets seem to be required and output in places they should not.
I am fairly shure it has nothing to do with the content of the required Asset however.
I don't think it's in the right place though, something which is accessibly from a controller method or event the request class would be nice, wouldn't it?