Example #1
0
 /**
  * Prepare links for the combined files and insert them in the processed HTML
  * 
  */
 public function insertJchLinks()
 {
     if (JchPlatformUtility::isMsieLT10()) {
         return;
     }
     $aLinks = $this->oParser->getReplacedFiles();
     if ($this->params->get('htaccess', 2) == 2) {
         JchOptimizeHelper::checkModRewriteEnabled($this->params);
     }
     $replace_css_links = FALSE;
     if ($this->params->get('css', '1') && !empty($aLinks['css'])) {
         $sCssCacheId = $this->getCacheId($aLinks['css']);
         $sCssCache = $this->combineFiles($aLinks['css'], $sCssCacheId, 'css');
         if ($this->params->get('pro_optimizeCssDelivery', '0')) {
             $sCriticalCss = '<style type="text/css">' . $this->sLnEnd . $sCssCache['criticalcss'] . $this->sLnEnd . '</style>' . $this->sLnEnd . '</head>';
             $sHeadHtml = str_replace('</head>', $sCriticalCss, $this->oParser->getHeadHtml());
             $this->oParser->setSearchArea($sHeadHtml, 'head');
             $sUrl = $this->buildUrl($sCssCacheId, 'css');
             $sUrl = str_replace('JCHI', '0', $sUrl);
             $this->loadCssAsync($sUrl);
         } else {
             $replace_css_links = TRUE;
         }
     }
     if ($this->params->get('javascript', '1') && !empty($aLinks['js'])) {
         $sJsCacheId = $this->getCacheId($aLinks['js']);
         $this->combineFiles($aLinks['js'], $sJsCacheId, 'js');
         $this->replaceLinks($sJsCacheId, 'js');
     }
     if ($replace_css_links) {
         $this->replaceLinks($sCssCacheId, 'css');
     }
 }
Example #2
0
 /**
  * Prepare links for the combined files and insert them in the processed HTML
  * 
  */
 public function insertJchLinks()
 {
     $aLinks = $this->oParser->getReplacedFiles();
     $params = $this->params;
     if ($this->params->get('htaccess', 2) == 2) {
         JchOptimizeHelper::checkModRewriteEnabled($this->params);
     }
     if ($params->get('javascript', 1)) {
         $sLink = $this->params->get('bottom_js', '0') == '2' ? '</title>' . $this->sLnEnd . $this->sTab : '';
         $sLink .= '<script type="text/javascript" src="URL"';
         $sLink .= $params->get('defer_js', 0) ? $this->isXhtml() ? ' defer="defer"' : ' defer' : '';
         $sLink .= $this->getAsyncAttribute();
         $sLink .= '></script>';
         $sNewJsLink = $params->get('bottom_js') == '1' ? $this->sTab . $sLink . $this->sLnEnd . '</body>' : $sLink;
         if (!empty($aLinks['js'])) {
             $this->processLink('js', $sNewJsLink);
         }
     }
     if ($this->oParser->enableCssCompression()) {
         $sNewCssLink = $this->params->get('bottom_js', '0') ? '</title>' . $this->sLnEnd . $this->sTab : '';
         $sNewCssLink .= '<link rel="stylesheet" type="text/css" ';
         $sNewCssLink .= 'href="URL"/>';
         if (!empty($aLinks['css'])) {
             $this->processLink('css', $sNewCssLink);
         }
     }
 }
Example #3
0
 /**
  * Prepare links for the combined files and insert them in the processed HTML
  * 
  */
 public function insertJchLinks()
 {
     $aLinks = $this->oParser->getReplacedFiles();
     if (!JchOptimizeHelper::isMsieLT10() && $this->params->get('combine_files_enable', '1')) {
         if ($this->params->get('htaccess', 2) == 2) {
             JchOptimizeHelper::checkModRewriteEnabled($this->params);
         }
         $replace_css_links = FALSE;
         if ($this->params->get('css', 1) && !empty($aLinks['css'])) {
             $sCssCacheId = $this->getCacheId($aLinks['css']);
             $sCssCache = $this->getCombinedFiles($aLinks['css'], $sCssCacheId, 'css');
             if ($this->params->get('pro_optimizeCssDelivery_enable', '0')) {
                 $sCriticalCss = '<style type="text/css">' . $this->sLnEnd . $sCssCache['criticalcss'] . $this->sLnEnd . '</style>' . $this->sLnEnd . '</head>';
                 $sHeadHtml = preg_replace('#</head>#i', JchOptimizeHelper::cleanReplacement($sCriticalCss), $this->oParser->getHeadHtml(), 1);
                 $this->oParser->setSearchArea($sHeadHtml, 'head');
                 $sUrl = $this->buildUrl($sCssCacheId, 'css');
                 $sUrl = str_replace('JCHI', '0', $sUrl);
                 $this->loadCssAsync($sUrl);
             } else {
                 $replace_css_links = TRUE;
             }
         }
         if ($this->params->get('javascript', 1) && !empty($aLinks['js'])) {
             $sJsCacheId = $this->getCacheId($aLinks['js']);
             $this->getCombinedFiles($aLinks['js'], $sJsCacheId, 'js');
             $this->replaceLinks($sJsCacheId, 'js');
         }
         if ($replace_css_links) {
             $this->replaceLinks($sCssCacheId, 'css');
         }
     }
     if (!empty($aLinks['img'])) {
         $this->addImgAttributes($aLinks['img']);
     }
     $this->runCronTasks();
 }