CDATA 出现在我的 HTML 页面中。为什么?
CDATA showing up in my HTML page. Why?
我有一个 HTML 页面,但是当我将它加载到我的 phone 时,有一个长文本以 "CDATA" 开头。
我没有在我的页面上添加任何类似的东西。我将我的 JavaScript 和 Gulp 缩小并连接到一个文件中。我加载了 velocity.js 和 jQuery 库。
当我重新加载页面几次时,长文本突然消失了。
我怎样才能摆脱这个问题?
我自己编写了所有代码,除了上面提到的那些之外,没有使用任何库。
非常感谢您的帮助!谢谢!
我认为问题出在页面速度脚本上,在该脚本中我可以看到这些行:
<script pagespeed_no_defer="">//<![CDATA[
(function(){var g=this,h=function(b,d){var a=b.split("."),c=g;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)a.length||void 0===d?c[e]?c=c[e]:c=c[e]={}:c[e]=d};var l=function(b){var d=b.length;if(0<d){for(var a=Array(d),c=0;c<d;c++)a[c]=b[c];return a}return[]};var m=function(b){var d=window;if(d.addEventListener)d.addEventListener("load",b,!1);else if(d.attachEvent)d.attachEvent("onload",b);else{var a=d.onload;d.onload=function(){b.call(this);a&&a.call(this)}}};var n,p=function(b,d,a,c,e){this.f=b;this.h=d;this.i=a;this.c=e;this.e={height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth};this.g=c;this.b={};this.a=[];this.d={}},q=function(b,d){var a,c,e=d.getAttribute("pagespeed_url_hash");if(a=e&&!(e in b.d))if(0>=d.offsetWidth&&0>=d.offsetHeight)a=!1;else{c=d.getBoundingClientRect();var f=document.body;a=c.top+("pageYOffset"in window?window.pageYOffset:(document.documentElement||f.parentNode||f).scrollTop);c=c.left+("pageXOffset"in window?window.pageXOffset:(document.documentElement||f.parentNode||f).scrollLeft);f=a.toString()+","+c;b.b.hasOwnProperty(f)?a=!1:(b.b[f]=!0,a=a<=b.e.height&&c<=b.e.width)}a&&(b.a.push(e),b.d[e]=!0)};p.prototype.checkImageForCriticality=function(b){b.getBoundingClientRect&&q(this,b)};h("pagespeed.CriticalImages.checkImageForCriticality",function(b){n.checkImageForCriticality(b)});h("pagespeed.CriticalImages.checkCriticalImages",function(){r(n)});var r=function(b){b.b={};for(var d=["IMG","INPUT"],a=[],c=0;c<d.length;++c)a=a.concat(l(document.getElementsByTagName(d[c])));if(0!=a.length&&a[0].getBoundingClientRect){for(c=0;d=a[c];++c)q(b,d);a="oh="+b.i;b.c&&(a+="&n="+b.c);if(d=0!=b.a.length)for(a+="&ci="+encodeURIComponent(b.a[0]),c=1;c<b.a.length;++c){var e=","+encodeURIComponent(b.a[c]);131072>=a.length+e.length&&(a+=e)}b.g&&(e="&rd="+encodeURIComponent(JSON.stringify(s())),131072>=a.length+e.length&&(a+=e),d=!0);t=a;if(d){c=b.f;b=b.h;var f;if(window.XMLHttpRequest)f=new XMLHttpRequest;else if(window.ActiveXObject)try{f=new ActiveXObject("Msxml2.XMLHTTP")}catch(k){try{f=new ActiveXObject("Microsoft.XMLHTTP")}catch(u){}}f&&(f.open("POST",c+(-1==c.indexOf("?")?"?":"&")+"url="+encodeURIComponent(b)),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(a))}}},s=function(){var b={},d=document.getElementsByTagName("IMG");if(0==d.length)return{};var a=d[0];if(!("naturalWidth"in a&&"naturalHeight"in a))return{};for(var c=0;a=d[c];++c){var e=a.getAttribute("pagespeed_url_hash");e&&(!(e in b)&&0<a.width&&0<a.height&&0<a.naturalWidth&&0<a.naturalHeight||e in b&&a.width>=b[e].k&&a.height>=b[e].j)&&(b[e]={rw:a.width,rh:a.height,ow:a.naturalWidth,oh:a.naturalHeight})}return b},t="";h("pagespeed.CriticalImages.getBeaconData",function(){return t});h("pagespeed.CriticalImages.Run",function(b,d,a,c,e,f){var k=new p(b,d,a,e,f);n=k;c&&m(function(){window.setTimeout(function(){r(k)},0)})});})();pagespeed.CriticalImages.Run('/mod_pagespeed_beacon','http://beta.tim-specht.com/sites/Praxis3/','l-uclZP3o3',true,false,'vYDWyUL8cpc');
//]]></script>
尝试删除这些行
我在 AWS 实例中的 wordpress 站点中遇到了同样的问题,在我的移动版页面中使用了 bitnami。这里的问题是 bitnami 默认加载 pagespeed。我在 aws 中通过 ssh 连接到我的服务器解决了这个问题,并使用 "cd .." 找到了这个文件(你可以通过 SSH 或 FTP 编辑这个文件)。这是 SSH 方式:
通过 ssh 连接到您的服务器。
在以下位置查找 "httpd.conf" 文件:
/opt/bitnami/apache2/conf/httpd.conf
使用"nano"命令打开文件。
nano /opt/bitnami/apache2/conf/httpd.conf
然后按 "ctrl + w" 并查找这两行:
Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf
在两行中使用“#”注释并保存文件:
#Include conf/pagespeed.conf
#Include conf/pagespeed_libraries.conf
然后用命令行重启apache:
sudo /opt/bitnami/ctlscript.sh restart apache
或者使用您自己的重启命令行就可以了
问题已解决。
希望对大家有所帮助
我有一个 HTML 页面,但是当我将它加载到我的 phone 时,有一个长文本以 "CDATA" 开头。 我没有在我的页面上添加任何类似的东西。我将我的 JavaScript 和 Gulp 缩小并连接到一个文件中。我加载了 velocity.js 和 jQuery 库。 当我重新加载页面几次时,长文本突然消失了。 我怎样才能摆脱这个问题? 我自己编写了所有代码,除了上面提到的那些之外,没有使用任何库。
非常感谢您的帮助!谢谢!
我认为问题出在页面速度脚本上,在该脚本中我可以看到这些行:
<script pagespeed_no_defer="">//<![CDATA[
(function(){var g=this,h=function(b,d){var a=b.split("."),c=g;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)a.length||void 0===d?c[e]?c=c[e]:c=c[e]={}:c[e]=d};var l=function(b){var d=b.length;if(0<d){for(var a=Array(d),c=0;c<d;c++)a[c]=b[c];return a}return[]};var m=function(b){var d=window;if(d.addEventListener)d.addEventListener("load",b,!1);else if(d.attachEvent)d.attachEvent("onload",b);else{var a=d.onload;d.onload=function(){b.call(this);a&&a.call(this)}}};var n,p=function(b,d,a,c,e){this.f=b;this.h=d;this.i=a;this.c=e;this.e={height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth};this.g=c;this.b={};this.a=[];this.d={}},q=function(b,d){var a,c,e=d.getAttribute("pagespeed_url_hash");if(a=e&&!(e in b.d))if(0>=d.offsetWidth&&0>=d.offsetHeight)a=!1;else{c=d.getBoundingClientRect();var f=document.body;a=c.top+("pageYOffset"in window?window.pageYOffset:(document.documentElement||f.parentNode||f).scrollTop);c=c.left+("pageXOffset"in window?window.pageXOffset:(document.documentElement||f.parentNode||f).scrollLeft);f=a.toString()+","+c;b.b.hasOwnProperty(f)?a=!1:(b.b[f]=!0,a=a<=b.e.height&&c<=b.e.width)}a&&(b.a.push(e),b.d[e]=!0)};p.prototype.checkImageForCriticality=function(b){b.getBoundingClientRect&&q(this,b)};h("pagespeed.CriticalImages.checkImageForCriticality",function(b){n.checkImageForCriticality(b)});h("pagespeed.CriticalImages.checkCriticalImages",function(){r(n)});var r=function(b){b.b={};for(var d=["IMG","INPUT"],a=[],c=0;c<d.length;++c)a=a.concat(l(document.getElementsByTagName(d[c])));if(0!=a.length&&a[0].getBoundingClientRect){for(c=0;d=a[c];++c)q(b,d);a="oh="+b.i;b.c&&(a+="&n="+b.c);if(d=0!=b.a.length)for(a+="&ci="+encodeURIComponent(b.a[0]),c=1;c<b.a.length;++c){var e=","+encodeURIComponent(b.a[c]);131072>=a.length+e.length&&(a+=e)}b.g&&(e="&rd="+encodeURIComponent(JSON.stringify(s())),131072>=a.length+e.length&&(a+=e),d=!0);t=a;if(d){c=b.f;b=b.h;var f;if(window.XMLHttpRequest)f=new XMLHttpRequest;else if(window.ActiveXObject)try{f=new ActiveXObject("Msxml2.XMLHTTP")}catch(k){try{f=new ActiveXObject("Microsoft.XMLHTTP")}catch(u){}}f&&(f.open("POST",c+(-1==c.indexOf("?")?"?":"&")+"url="+encodeURIComponent(b)),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(a))}}},s=function(){var b={},d=document.getElementsByTagName("IMG");if(0==d.length)return{};var a=d[0];if(!("naturalWidth"in a&&"naturalHeight"in a))return{};for(var c=0;a=d[c];++c){var e=a.getAttribute("pagespeed_url_hash");e&&(!(e in b)&&0<a.width&&0<a.height&&0<a.naturalWidth&&0<a.naturalHeight||e in b&&a.width>=b[e].k&&a.height>=b[e].j)&&(b[e]={rw:a.width,rh:a.height,ow:a.naturalWidth,oh:a.naturalHeight})}return b},t="";h("pagespeed.CriticalImages.getBeaconData",function(){return t});h("pagespeed.CriticalImages.Run",function(b,d,a,c,e,f){var k=new p(b,d,a,e,f);n=k;c&&m(function(){window.setTimeout(function(){r(k)},0)})});})();pagespeed.CriticalImages.Run('/mod_pagespeed_beacon','http://beta.tim-specht.com/sites/Praxis3/','l-uclZP3o3',true,false,'vYDWyUL8cpc');
//]]></script>
尝试删除这些行
我在 AWS 实例中的 wordpress 站点中遇到了同样的问题,在我的移动版页面中使用了 bitnami。这里的问题是 bitnami 默认加载 pagespeed。我在 aws 中通过 ssh 连接到我的服务器解决了这个问题,并使用 "cd .." 找到了这个文件(你可以通过 SSH 或 FTP 编辑这个文件)。这是 SSH 方式:
通过 ssh 连接到您的服务器。
在以下位置查找 "httpd.conf" 文件:
/opt/bitnami/apache2/conf/httpd.conf
使用"nano"命令打开文件。
nano /opt/bitnami/apache2/conf/httpd.conf
然后按 "ctrl + w" 并查找这两行:
Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf
在两行中使用“#”注释并保存文件:
#Include conf/pagespeed.conf
#Include conf/pagespeed_libraries.conf
然后用命令行重启apache:
sudo /opt/bitnami/ctlscript.sh restart apache
或者使用您自己的重启命令行就可以了
问题已解决。
希望对大家有所帮助