Slide 33
Slide 33 text
Preload and Push!
Tim Burt
github.com/DorsetDigital
Give the browser a hand
protected function init()
{
parent::init();
$preload = HTML::createTag('link', [
'rel' => 'preconnect',
'href' => 'https://use.typekit.net'
]);
$preload .= HTML::createTag('link', [
'rel' => 'preconnect',
'href' => 'https://p.typekit.net',
'crossorigin' => 'anonymous'
]);
Requirements::insertHeadTags($preload);
Requirements::css('https://use.typekit.net/eor1njj.css', '', ['preload' => true]);
Requirements::javascript('https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/gsap.min.js', ['type' => false]);
Requirements::javascript('https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.0/ScrollTrigger.min.js', ['type' => false]);
Requirements::css('themes/main/client/dist/css/common.css', '', ['push' => true]);
Requirements::javascript('themes/main/client/dist/javascript/lazyload_config.js', ['inline' => true, 'type' => false]);
Requirements::javascript('themes/main/client/dist/javascript/core.js', ['inline' => true]);
Requirements::javascript('themes/main/client/dist/javascript/common.js', ['type' => false, 'async' => true, 'defer' => true]);
Requirements::css('themes/main/client/dist/css/core.css', '', ['inline' => true]);
}
(Uses enhanced requirements module)