Output loadJS content in custom location

Description

Ability to output the content from loadJS in a custom location. Specifically right before the closing html tag.

Suggested solution: output to request variable for the developer to use where desired.

  • add attribute jsVarname (default: request.jsoutput)

  • add attribute bOutputInHead (default: up to you)

Personally I'd rather the default to be false on the boolean attribute, but I can understand if you'd prefer to have it to true for backwards compatibility.

Environment

None

Activity

Show:
Sean Coyne
February 10, 2014, 8:24 PM

I think its a good enhancement. I would default it to the head. Maybe a site wide configuration option to set the request variable name and whether it outputs in the head section or not? This would be an easier solution rather than have to add new attributes then have to go through your code and find all the places you use it and update them to get the new functionality. Instead you could just change the settings, and then in your code, before your </body> tag just output the variable and done. This way you also dont have to remember to set it every time you use the tag in the future, and makes your code (for plugins and such) more portable if used on a site where the assets should be loaded in the head rather than somewhere else.

Justin Carter
February 10, 2014, 10:32 PM

Yep, thumbs up Just adding my comments from the farcry-dev thread for future reference:

https://groups.google.com/forum/#!topic/farcry-dev/KxmqE-RIfvQ

"I've been wanting to do this for core except there is a bunch of code that is injected using skin:onReady and skin:htmlHead that relies on having jQuery already loaded in the head, so we also need a way to shift that code to the footer (but below the tags which load scripts)."

From memory, due to the way minification and JS output currently works, I think we'd need to use a new tag (rather than a variable) to output JS in the footer (e.g. skin:footerJS?). We would need to pick the appropriate libraries out of the existing array that is in the request scope and use the same minification process, and then allow onRequestEnd to still do it's thing for anything that does need to be outputted in the <head> (Google Analytics?).

Assignee

Unassigned

Reporter

Jeff Coughlin

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure