Process html_head for JS libraries
Previously we just looked in the attached libraries, we also apparently need to look in the html_head for JS scripts that could be potientially loaded.
Shift this processing into its own helper function and return all the necessary scripts.
Closes #3534375