1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Added an option for pre-loading of library assets. More info: https://web.dev/uses-rel-preload/

This commit is contained in:
Cameron
2020-12-02 13:17:23 -08:00
parent 594c6043db
commit c9bc789b79
5 changed files with 72 additions and 4 deletions

View File

@@ -773,10 +773,17 @@ class e_jsmanager
/**
* Add a <link> tag to the head.
* @param array $attributes key>value pairs
* @param bool $browserCache - set to true to add the cacheId to the href.
* @example addLink(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
*/
public function addLink($attributes=array())
public function addLink($attributes=array(), $browserCache=false)
{
if(!empty($attributes['href']) && $browserCache === true)
{
$attributes['href'] .= "?".$this->getCacheId();
}
if(!empty($attributes))
{
$this->_e_link[] = $attributes;
@@ -790,7 +797,6 @@ class e_jsmanager
*/
public function renderLinks()
{
if(empty($this->_e_link))
{
return null;
@@ -812,6 +818,12 @@ class e_jsmanager
$text .= "\n<link";
foreach($v as $key=>$val)
{
if($key === 'crossorigin' && $val === true)
{
$text .= " crossorigin";
continue;
}
if(!empty($val))
{
$text .= " ".$key."=\"".$val."\"";