There are three classes of problem that come up.
1. Independent external resources: Something like an image. This isn't part of anything else and can be generated and served all by itself.
3. Non-local modifications to the HTML output. If I have a button that requires some JS, that JS needs to modify the header of the HTML output to either have the code embedded or have a reference to the external resource. Same with CSS. Right now I know that JS gets embedded all over the place but this is not correct.
Each of these problems may have different solutions.