Delay Loading a Block Automatically after Page Loads

Permalink
Just a thought. Is there a way to delay loading of a block, such as a slider, after the page loads? Have product slide blocks at the bottom of pages and it would not make a difference to the user experience if they were loading once the page loaded. Looking to speed up initial page loads.

MrGrowBizz
 
Mainio replied on at Permalink Best Answer Reply
Mainio
No, this is not possible in current versions of concrete5. However, the core team has looked into this issue and they are adding few performance tuning things in the upcoming 5.5 release.

Usually you add page header items in the block's controller like this:
// This functionality should be inside the on_page_view function
function on_page_view() {
   $this->addHeaderItem(Loader::helper('html')->javascript('your_javascript.js', 'your_package_handle'));
}


In 5.5 you can also add footer items exactly the same way:
function on_page_view() {
   $this->addFooterItem(Loader::helper('html')->javascript('your_javascript.js', 'your_package_handle'));
}


However, there's no "single button" from which you could enable this for all JS in all blocks. So, how the JS is included on the page depends on the block developer but you can always do your own overrides to the block controllers if you'd like to.

Also, why this is not and should not be possible from a single setting is that some JS still requires to be in the header. It depends on how the JS is written. Therefore, it should not be possible to "force" all the JS in the footer because some scripts might break that way.


Br,
Antti / Mainio
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Mainio, Thanks for your support! Thought this may be the case as I have used Miser to have Jscript moved to loading last. Was hopeful there may be another way to have the block automatically activate after a full load of the page. Thanks for giving a little detail on 5.5 as I am patiently waiting for its release. Tim
JohntheFish replied on at Permalink Reply
JohntheFish
There is a new ajax paging block that can be used to achieve this sort of thing.http://www.concrete5.org/marketplace/addons/rapid-ajax-paging/...
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
John, Thanks for the heads up! Nice add-on, will look further into, if not for the current project, for another. Thumbs up for Tony, great looking example site as well. Tim