Starting in Wicket 9, an issue cropped up with how JS is evaluated when loaded through Ajax. It appears as though JS in the component is evaluated before the references in <wicket:head> or #renderHead() are resolved. This leads to initialization and reference errors in the first rendering if said JS in the component references the libraries in the header. Subsequent usages are fine as the referenced libraries are then cached.
I'm not familiar with Wicket internals, but this to me seems related to what Martin brought up in WICKET-6840. The comment reads:
WICKET-6703 Wicket was using <prepend-evaluation> elements in the Ajax XML response, which were processed before any component replacement. After WICKET-6703 we use <header-contribution> for both prepend and append JS. With the change above the issue is worked around but the prepend JS contributed by AjaxIndicatorAppender is executed after the component replacements."
I've attached a sample quickstart that is a simplified version of the charting issue I mentioned having in that ticket. It is a custom component that pulls a simple JS library in the header and calls it inline. The issue can be observed through the browser JS console when clicking the link.