Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
消除codeigniter php中折叠内容上方的渲染阻塞JavaScript和CSS_Php_Codeigniter - Fatal编程技术网

消除codeigniter php中折叠内容上方的渲染阻塞JavaScript和CSS

消除codeigniter php中折叠内容上方的渲染阻塞JavaScript和CSS,php,codeigniter,Php,Codeigniter,通过pagespeed insights进行检查,发现此错误为“消除折叠内容上方的渲染阻塞JavaScript和CSS” 我已经尝试过这些代码来删除渲染阻塞javascript <script type="text/javascript"> function downloadJSAtOnload() { var element = document.createElement("script"); element.src = "http://www.staging.websi

通过pagespeed insights进行检查,发现此错误为“消除折叠内容上方的渲染阻塞JavaScript和CSS”

我已经尝试过这些代码来删除渲染阻塞javascript

<script type="text/javascript">
 function downloadJSAtOnload() {
 var element = document.createElement("script");
  element.src = "http://www.staging.website.com/theme/js/jquery.min.js";
   element.src="http://www.staging.website.com/theme/js/bootstrap.min.js
   element.src="http://www.staging.website.com/theme/engine1/jquery.js";
 document.body.appendChild(element);
 }
 if (window.addEventListener)
 window.addEventListener("load", downloadJSAtOnload, false);
 else if (window.attachEvent)
 window.attachEvent("onload", downloadJSAtOnload);
 else window.onload = downloadJSAtOnload;
 </script

函数downloadJSAtOnload(){
var元素=document.createElement(“脚本”);
element.src=”http://www.staging.website.com/theme/js/jquery.min.js";
元素。src=”http://www.staging.website.com/theme/js/bootstrap.min.js
元素。src=”http://www.staging.website.com/theme/engine1/jquery.js";
document.body.appendChild(元素);
}
if(window.addEventListener)
addEventListener(“加载”,downloadJSAtOnload,false);
else if(窗口附件)
window.attachEvent(“onload”,downloadJSAtOnload);
else window.onload=下载jsatonload;

我们发现,有时一种方法依赖于JS put 2作为一个,但这并不总是有效。我们发现,将JS脚本放在登录页中消除了渲染阻塞JavaScript,但youn已经将其放在网站的所有页面中。我们通过将代码放在登录页中消除了渲染阻塞CSS,这使我们从google页面获得了100%的支持insite但在手机上的测试中,它减慢了网站的速度,因此当js使用和css使用返回到百分之八十六时,css示例取自“是”,您需要使用async属性来异步调用js文件如果我为javascript文件添加async,它将不起作用javascript@SaadSuri在添加css文件后,它将获得另一个问题为“对可见内容进行优先级排序您的页面需要额外的网络往返才能呈现上述内容。为获得最佳性能,请减少在折叠内容上方渲染所需的HTML量。”
<script type="text/javascript">
 function downloadJSAtOnload() {
 var element = document.createElement("script");
  element.src = "http://www.staging.website.com/theme/js/jquery.min.js";
   element.src="http://www.staging.website.com/theme/js/bootstrap.min.js
   element.src="http://www.staging.website.com/theme/engine1/jquery.js";
 document.body.appendChild(element);
 }
 if (window.addEventListener)
 window.addEventListener("load", downloadJSAtOnload, false);
 else if (window.attachEvent)
 window.attachEvent("onload", downloadJSAtOnload);
 else window.onload = downloadJSAtOnload;
 </script
<script>
  /*!
  loadCSS: load a CSS file asynchronously.
  */
  function loadCSS(href){
    var ss = window.document.createElement('link'),
        ref = window.document.getElementsByTagName('head')[0];

    ss.rel = 'stylesheet';
    ss.href = href;

    // temporarily, set media to something non-matching to ensure it'll
    // fetch without blocking render
    ss.media = 'only x';

    ref.parentNode.insertBefore(ss, ref);

    setTimeout( function(){
      // set media back to `all` so that the stylesheet applies once it loads
      ss.media = 'all';
    },0);
  }
  loadCss('styles.css');
</script>
<noscript>
  <!-- Let's not assume anything -->
  <link rel="stylesheet" href="styles.css">
</noscript>