Output loadJS content before closing body tag (feature request)

15 views
Skip to first unread message

Jeff Coughlin

unread,
Feb 10, 2014, 3:26:54 PM2/10/14
to farcr...@googlegroups.com
Now that everything has been going html5 and people are pushing for faster load times (especially with mobile website support), one feature FarCry could really use is the ability to output loadJS content before the closing body tag. This can be done simply by saving the data to a request variable and giving us the option to either output it in the head block (current way it works) or use the request variable content wherever we want.

Can I get any +1 votes on this? :)

https://farcry.jira.com/browse/FC-2852

--
Jeff Coughlin

Justin Carter

unread,
Feb 10, 2014, 3:42:03 PM2/10/14
to farcr...@googlegroups.com

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). I don't think I'll have time to do this for 7.0, so probably 7.1.

At the moment we have some sites where we place the JS in the footer manually, without using loadJS, and it's not too inconvenient if your front end just uses a couple of JS files, but may be a hassle if you use more than that.

cheers,
Justin

--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
---
You received this message because you are subscribed to the Google Groups "farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to farcry-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sean Coyne

unread,
Feb 10, 2014, 3:59:51 PM2/10/14
to farcr...@googlegroups.com
If you have lots of js files, it might be better to start using a modular system to load them as they are required and forego FarCry's handling.  Something like require.js

Justin Carter

unread,
Feb 10, 2014, 4:21:52 PM2/10/14
to farcr...@googlegroups.com

Yeah, I'd be tempted to recommend everyone use Grunt (or similar), Require.js, and do their own CSS and JS minification (a few less things for FarCry Core to do!), but not everyone would be comfortable with that :)

In general though, I think 7.1 needs to focus on performance a bit more, so I'm sure there's something we can do.

Blair McKenzie

unread,
Feb 10, 2014, 5:29:13 PM2/10/14
to Unname
For the moment you can call core:inHead directly with variable attribute - the tag will return an array of { id, html } structs in that variable. The IDs are all one of "onReady", "stylesheet-#libraryid#" and "javascript-#libraryid#". Note that the onReady html doesn't include the $j(function(){ ... }); wrapper.

I originally added r_html so we could capture js/css requirements for an ajax response and pass them back in JSON, but it should work equally well for your case. Having the ids will allow you manually pick which libraries go in the head and which ones inline.

Blair

Justin Carter

unread,
Feb 10, 2014, 5:37:26 PM2/10/14
to farcr...@googlegroups.com
Also, be very careful relying on core:cssInHead/jsInHead because they could die in a fire at any time! The readme.txt in that folder says:

"Do not use these tags outside of /farcry/core! You have been warned."

Hahaha :)
Reply all
Reply to author
Forward
0 new messages