[coldbox:15181] [ColdBox 3.5.1] Add asset before the end of document

Hi there.

As far as i know it only sends it to the header if you set the sendtohead argument to true. Otherwise addAsset puts javascript inline.

If you realy need it to be just before the body tag then you could use good old cfsavecontent tags and cfoutput it in your layout file…

Cheers,
Tom

I typically use the preRender interception point, then do something like…

I use cfsavecontent to build up the inlineJS string. But as Tom suggested, if you’re not doing additional work, a simple output in your layout file would be fine also.

/**

  • I add any inline assets to the body of the output

*/

component {

property name=“jsMin” inject=“coldbox:myPlugin:jsMin”;

void function preProcess(event,struct interceptData){

var rc = event.getCollection();

var prc = event.getCollection(private=true);

//setup the variables to store the inline files

prc.inlineJS = “”; }

void function preRender(event,struct interceptData){

var rc = event.getCollection();

var prc = event.getCollection(private=true);

var inline = ‘’;

if (len(prc.inlineJS)) {

prc.inlineJS = jsMin.minifyString(prc.inlineJS,“JS”);

inline = inline & ‘’;

}

inline = inline & ‘’;

interceptData.renderedContent = replace(interceptData.renderedContent,’’,inline);

}

}