Example #1
0
 /**
  * Prepare links for the combined files and insert them in the processed HTML
  * 
  */
 public function insertJchLinks()
 {
     if (JchOptimizeHelper::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->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 = 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->getCombinedFiles($aLinks['js'], $sJsCacheId, 'js');
         $this->replaceLinks($sJsCacheId, 'js');
     }
     if ($replace_css_links) {
         $this->replaceLinks($sCssCacheId, 'css');
     }
     if ($this->params->get('pro_lazyload', '0')) {
         $this->showLazyLoadImages();
     }
     $this->runCronTasks();
 }
Example #2
0
 /**
  * Removes applicable js and css links from search area
  * 
  */
 public function parseHtml()
 {
     JCH_DEBUG ? JchPlatformProfiler::start('SetUpExcludes') : null;
     $oParams = $this->params;
     $aCBArgs = array();
     $this->getHeadHtml();
     $this->getBodyHtml();
     if (JchOptimizeHelper::isMsieLT10()) {
         return;
     }
     loadJchOptimizeClass('JchPlatformExcludes');
     $aExJsComp = $this->getExComp($oParams->get('excludeJsComponents', ''));
     $aExCssComp = $this->getExComp($oParams->get('excludeCssComponents', ''));
     $aExcludeJs = JchOptimizeHelper::getArray($oParams->get('excludeJs', ''));
     $aExcludeCss = JchOptimizeHelper::getArray($oParams->get('excludeCss', ''));
     $aExcludeScript = JchOptimizeHelper::getArray($oParams->get('pro_excludeScripts'));
     $aExcludeStyle = JchOptimizeHelper::getArray($oParams->get('pro_excludeStyles'));
     $aExcludeScript = array_map(function ($sScript) {
         return stripslashes($sScript);
     }, $aExcludeScript);
     $aCBArgs['excludes']['js'] = array_merge($aExcludeJs, $aExJsComp, array('.com/maps/api/js', '.com/jsapi', '.com/uds', 'typekit.net'), JchPlatformExcludes::head('js'));
     $aCBArgs['excludes']['css'] = array_merge($aExcludeCss, $aExCssComp, JchPlatformExcludes::head('css'));
     $aCBArgs['excludes']['js_script'] = $aExcludeScript;
     $aCBArgs['excludes']['css_script'] = $aExcludeStyle;
     $aCBArgs['removals']['js'] = JchOptimizeHelper::getArray($oParams->get('removeJs', ''));
     $aCBArgs['removals']['css'] = JchOptimizeHelper::getArray($oParams->get('removeCss', ''));
     JCH_DEBUG ? JchPlatformProfiler::stop('SetUpExcludes', TRUE) : null;
     $this->initSearch($aCBArgs);
     $this->runCookieLessDomain();
     $this->lazyLoadImages();
 }