• Hi man ,

    Your plugin it’s very awesome , i can’t believe this plugin magic , with Autoptimize and some tips my score it’s 98/100 in Google speed test ( Pro3xplain[dot]com ) and i can make it 100/100 but i didn’t Minifi the external files of Google Adsense .

    I can’t minify it with Autoptimize , so what i did it’s : i copied some external files ( e.g : Google Analytics , Twitter Widget …) to my host . And i can make cron job , every 12H refresh these external files ( copied the new files from the original website and pasted to my host ) .

    The problem here , it’s the external files of some other plugin (e.g : jetpack , facebook comments … ) you must search it , and chage the URL from external to internal .

    Autoptimize can detect the external files but it doesn’t minify it , so i share with you my ideas , if you can update the plugin to minify external files ( css/js ) and refresh it every 12H

    https://www.ads-software.com/plugins/autoptimize/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Frank Goossens

    (@futtta)

    That’s an interesting idea Pro3xplain, I’ve added it to my wishlist. No commitment on whether this will be implemented and if so, when, as there’s a lot of stuff on that wishlist, so if you have some code to share you’re more then welcome ??

    frank

    Thread Starter Pro 3xpalin

    (@pro-3xpalin)

    Hi Frank ,

    This is the code to update the external files and about the cron job i do it from the Host manager … but i think you must add it like option in the plugin … because there is a different Admin Panel ( ovh , cpanel , isp … ) .

    <?
    // script to update local version of Google analytics script
    
    // Remote file to download
    $remoteFile = 'https://www.google-analytics.com/ga.js';
    $localfile = 'ENTER YOUR ABSOLUTE PATH TO THE FILE HERE';
    //For Cpanel it will be /home/USERNAME/public_html/ga.js
    
    // Connection time out
    $connTimeout = 10;
    $url = parse_url($remoteFile);
    $host = $url['host'];
    $path = isset($url['path']) ? $url['path'] : '/';
    
    if (isset($url['query'])) {
      $path .= '?' . $url['query'];
    }
    
    $port = isset($url['port']) ? $url['port'] : '80';
    $fp = @fsockopen($host, '80', $errno, $errstr, $connTimeout );
    if(!$fp){
      // On connection failure return the cached file (if it exist)
      if(file_exists($localfile)){
        readfile($localfile);
      }
    } else {
      // Send the header information
      $header = "GET $path HTTP/1.0\r\n";
      $header .= "Host: $host\r\n";
      $header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\r\n";
      $header .= "Accept: */*\r\n";
      $header .= "Accept-Language: en-us,en;q=0.5\r\n";
      $header .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
      $header .= "Keep-Alive: 300\r\n";
      $header .= "Connection: keep-alive\r\n";
      $header .= "Referer: https://$host\r\n\r\n";
      fputs($fp, $header);
      $response = '';
    
      // Get the response from the remote server
      while($line = fread($fp, 4096)){
        $response .= $line;
      }
    
      // Close the connection
      fclose( $fp );
    
      // Remove the headers
      $pos = strpos($response, "\r\n\r\n");
      $response = substr($response, $pos + 4);
    
      // Return the processed response
      echo $response;
    
      // Save the response to the local file
      if(!file_exists($localfile)){
        // Try to create the file, if doesn't exist
        fopen($localfile, 'w');
      }
    
      if(is_writable($localfile)) {
        if($fp = fopen($localfile, 'w')){
          fwrite($fp, $response);
          fclose($fp);
        }
      }
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘can'i Minify external files ?’ is closed to new replies.