New feature: Progressive booting

Progressive booting is a technique to initially ship the minimum needed JavaScript, as to keep the time-to-interactive close to the first meaningful paint. We can then boot the non-essential Javascript later on, either on-demand or as time allows.

PoP has implemented 2 priorities when executing Javascript functions: “critical” and “non-critical”. The critical Javascript will be executed immediately during the page load, whereas the non-critical one will be executed only after the page is loaded. Quite importantly, all Javascript assets containing the methods which have been set as non-critical will be loaded using the “defer” attribute, which also makes the corresponding asset be loaded only after the page is loaded, effectively bringing forward the time-to-interactive of the application.

To define if a method is either critical or non-critical is very simple. By default, all methods are set as non-critical. This is so as to force the developer to think which methods are indeed critical, and define them explicitly. So, to mark a method as non-critical, is the same as just adding a method to execute on the DOM:

function get_block_jsmethod($template_id, $atts) {

  $ret = parent::get_block_jsmethod($template_id, $atts);

  $this->add_jsmethod($ret, 'calendar');

  return $ret;
}

And to define a method to be critical:

function get_block_jsmethod($template_id, $atts) {

  $ret = parent::get_block_jsmethod($template_id, $atts);

  $this->add_jsmethod($ret, 'calendar', '', false, POP_PROGRESSIVEBOOTING_CRITICAL);

  return $ret;
}

So, the only difference is adding attribute POP_PROGRESSIVEBOOTING_CRITICAL as 5th parameter to function add_jsmethod (parameters 3 and 4 can be ignored for our case).

As usual, enjoy!


Sign up to our newsletter:

Welcome to the PoP framework!
Break the information monopoly

the PoP framework is open source software which aims to decentralize the content flow and break the information monopoly from large internet corporations. Read more.