Store Meta / JS / CSS in buffer

To be clear, I’m pretty sure HTMLHelper already has an option for inserting your assets into the header using CFHTMLHead. The trick is that doesn’t work when running events from within ajax calls which return their payload as JSON or something similar that blows up when JS is inserted at the beginning of the request. (Save a few hackish and platform-specific ways at getting the head buffers out of the Java pageContext) So I tend to not use CFHTMLHead as a rule

That is why it’s important for me to be able to not only defer the output, but to also be able to control its output. However, the next issue I typically run into is that if you are rendering a view that is part of a layout, and you are adding assets in the view, the first half of the layout has already been rendered (at least the parts prior to the renderView() all) which makes it impossible to stick any of your defered assets at the top of the layout save a preRender interceptor that adds it in right before the rendered output makes its way back to the browser.

~Brad

exactly.

What I was thinking is to have the addAssetCSS(Header=true), addAssetJS(Header=true), etc…

and then you could call the groups of array cssHeaderArray and cssFooterArray. The groups could be minified via jsmin and combined together in a single cache file for header and for footer.


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com