1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 17:14:42 +02:00

Closes #618, #2599 Added simple options for including 'async' or 'defer' when using e107::js('header') and/or e107::js('footer').

Usage example: e107::js('footer', 'https://www.google.com/recaptcha/api.js?hl=en', ['defer','async']);
This commit is contained in:
Cameron
2021-12-27 15:21:18 -08:00
parent f58734346e
commit c96d64e275
2 changed files with 36 additions and 3 deletions

View File

@@ -191,6 +191,11 @@
'zone' => 3,
'opts' => array('defer'=>true)
),
4 => array(
'file' => 'https://somewhere/async.js',
'zone' => 4,
'opts' => array('defer', 'async')
),
);
@@ -210,6 +215,10 @@
$this->assertStringContainsString('<script type="text/javascript" src="https://somewhere/something.min.js" defer></script>', $result);
$this->assertStringContainsString('zone #3', $result);
$result = $this->js->renderJs('header', 4, true, true);
$this->assertStringContainsString('<script type="text/javascript" src="https://somewhere/async.js" defer async></script>', $result);
$this->assertStringContainsString('zone #4', $result);
}
public function testFooterFile()
@@ -237,6 +246,12 @@
'opts' => array('defer'=>true)
),
4 => array(
'file' => 'https://somewhere/async.js',
'zone' => 4,
'opts' => array('defer', 'async')
),
);
@@ -255,6 +270,10 @@
$this->assertStringContainsString('<script type="text/javascript" src="https://somewhere/something.min.js" defer></script>', $result);
$this->assertStringContainsString('priority #3', $result);
$result = $this->js->renderJs('footer', 4, true, true);
$this->assertStringContainsString('<script type="text/javascript" src="https://somewhere/async.js" defer async></script>', $result);
$this->assertStringContainsString('priority #4', $result);
}
/*
public function testSetDependency()