compression_test [ WordPress Function ]
| Defined at: |
|
Test support for compressing JavaScript from PHP
Outputs JavaScript that tests if compression from PHP works as expected and sets an option with the result. Has no effect when the current user is not an administrator. To run the test again the option 'can_compress_scripts' has to be deleted.
Source
<?php
function compression_test() {
?>
<script type="text/javascript">
/* <![CDATA[ */
var testCompression = {
get : function(test) {
var x;
if ( window.XMLHttpRequest ) {
x = new XMLHttpRequest();
} else {
try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
}
if (x) {
x.onreadystatechange = function() {
var r, h;
if ( x.readyState == 4 ) {
r = x.responseText.substr(0, 18);
h = x.getResponseHeader('Content-Encoding');
testCompression.check(r, h, test);
}
}
x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
x.send('');
}
},
check : function(r, h, test) {
if ( ! r && ! test )
this.get(1);
if ( 1 == test ) {
if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
this.get('no');
else
this.get(2);
return;
}
if ( 2 == test ) {
if ( '"wpCompressionTest' == r )
this.get('yes');
else
this.get('no');
}
}
};
testCompression.check();
/* ]]> */
</script>
<?php
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Dan's Motorcycle Compression Testing
The first thing I do, when a non running bike comes in, is to run a compression test. If the engine does not have at least 100 PSI (Pounds per Square Inch) in ...
www.dansmc.com - How to Perform a Cylinder Compression Test - YouTube
May 5, 2008 ... This clip lists the steps for performing a cylinder compressions test. It covers disabling the ignition and fuel system, hooking up a battery charger ...
www.youtube.com - What will a compression test tell me? — Yahoo! Autos
Answer: It will tell you if your engine has good compression. An engine is essentially a self-powered air pump, so it needs good compression to run efficiently,...
autos.yahoo.com - How To Do an Engine Compression Test - Compression Testing ...
Your engine's compression can tell a lot about its inner health. Compression tests will reveal these numbers and allow you to troubleshoot the problem.
autorepair.about.com