rviscomi/capo.js

Could capo be used to automate ordering of head elements as part of a build process

philnash opened this issue · 3 comments

I just learned about capo and think it's very cool. I applied it to my own site and found that I could fix some ordering, but due to the way that Astro injects CSS and scripts at the end of the <head>, I wasn't able to entirely make capo happy. I noticed that the docs site is built using Astro's starlight, so has the same issue.

I wondered if capo could be used to automatically re-order the items in the <head> so that it could be run during the build process of a site. That way you can write the elements out in whatever order makes sense to you, and frameworks can inject parts in whatever order works for them, and then a capo plugin could come in and set the order straight.

Is this possible with how capo works today? And if not, is it something that capo could be extended to do?

Thanks for the suggestion, and yes I'd love to see something like that. #45 and #23 will hopefully provide more modularity for these kinds of tools to be built on top of the core ruleset. So it's not ready today, but should be in the near future. I'm making some progress on it in this branch. Let me know if there's anything you'd be interested to work on to make this happen!

Awesome, I'd love to help out if I can. I'll see what I can do to understand the existing codebase and if there's anything you can point me towards, I'll take a crack.

FYI I've just published Capo to npm as part of #24, so it should be unblocked if any downstream projects wanted to integrate it into their build process.

Was there anything else you think we might need in order to support more of those kinds of use cases?