Title: Protocol-less URL support
Last modified: August 21, 2016

---

# Protocol-less URL support

 *  Resolved [RossWPDev](https://wordpress.org/support/users/rosswpdev/)
 * (@rosswpdev)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/)
 * Hello
 * On my site I have Autoptimize (latest version 1.8.1) (which is brilliant by the
   way) installed along with WooCommerce (2.1.5) and I have noticed that starting
   with WooCommerce version 2.1 they now use protocol-less URL’s e.g.
 * `//example.com/wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.
   min.js?ver=2.1.5`
 * Is there anyway I can get Autoptimize to pick these up? If I modify the core 
   WooCommerce code that add’s these resources by adding a protocol they are then
   picked up by Autoptimize, but obviously I don’t want to modify core files!
 * Any help would be greatly appreciated.
 * Many Thanks,
    Ross
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705633)
 * I’ll look into that, a solution for that might just still make it into 1.8.2.
   Now that I come to think of it; maybe I should switch to protocol-less URL’s.
   What do you think?
 *  Thread Starter [RossWPDev](https://wordpress.org/support/users/rosswpdev/)
 * (@rosswpdev)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705652)
 * Great, thanks, would be good to see this in 1.8.2 🙂
 * I believe that the advantage of using the protocol-less urls are that it allows
   them to inherit the pages current protocol (http / https) preventing the need
   for any logic in the code to work out the current pages protocol. Which all sounds
   good..
 * Found this article which goes over the topic in more detail [http://www.paulirish.com/2010/the-protocol-relative-url](http://www.paulirish.com/2010/the-protocol-relative-url)
 * Thanks,
    Ross
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705720)
 * Hi Ross;
    Not going to change output for now, but regarding aggregating protocol-
   less JS/CSS-links, could you try this?
 * 1. Open up /wp-content/plugins/autoptimize/classes/autoptimizeBase.php
    2. On
   line 26 change:
 *     ```
       //Converts an URL to a full path
       	protected function getpath($url) {
       		if ((strpos($url,'//')===false) && 	(strpos($url,parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST))===false))		{
       			$url = AUTOPTIMIZE_WP_SITE_URL.$url;
       		}
               $path = str_replace(AUTOPTIMIZE_WP_ROOT_URL,'',$url);
       	    if(preg_match('#^((https?|ftp):)?//#i',$path)) {
                   /** External script/css (adsense, etc) */
              		return false;
              	}
               $path = str_replace('//','/',WP_ROOT_DIR.$path);
               return $path;
       	}
       ```
   
 * into:
 *     ```
       //Converts an URL to a full path
       	protected function getpath($url) {
       		if (strpos($url,'//')===0) {
       			$url = "http:".$url;
       		} else if ((strpos($url,'//')===false) && (strpos($url,parse_url(AUTOPTIMIZE_WP_SITE_URL,PHP_URL_HOST))===false)) {
       			$url = AUTOPTIMIZE_WP_SITE_URL.$url;
       		}
               $path = str_replace(AUTOPTIMIZE_WP_ROOT_URL,'',$url);
       	    if(preg_match('#^((https?|ftp):)?//#i',$path)) {
                   /** External script/css (adsense, etc) */
              		return false;
              	}
               $path = str_replace('//','/',WP_ROOT_DIR.$path);
               return $path;
       	}
       ```
   
 * 3. save file
    4. empty Autoptimize Cache (and whatever page caching plugin you
   use).
 * Based on (limited) local tests this should do the trick. If this indeed does 
   work, it’ll be included in 1.8.2.
 * frank
 *  Thread Starter [RossWPDev](https://wordpress.org/support/users/rosswpdev/)
 * (@rosswpdev)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705806)
 * Hey futtta
 * Thanks for the reply. I’ve added in the updated function and it looks like it’s
   working great!
 * Thanks,
    Ross
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705808)
 * great, thanks for the feedback. enjoy your weekend!
 * frank
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705816)
 * by the way, get regular questions about how to configure autoptimize for woocommerce,
   would you mind sharing your configuration?
 *  Thread Starter [RossWPDev](https://wordpress.org/support/users/rosswpdev/)
 * (@rosswpdev)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705854)
 * Hey
 * Sure, although I have not needed to do much in order to get Autoptimize working
   with WooCommerce….
 * My current setup is a standard WooCommerce install (2.1.5) with latest WordPress(
   3.8.1).
 * **My Autoptimize settings are:**
    - Optimize HTML Code?: true
    - Optimize JavaScript Code?: true (exclude jQuery.js)
    - Optimize CSS Code?: true
    - Save aggregated script/css as static files?: true
 * (all other fields are unchecked)
 * If anyone has any specific questions relating to a working WooCommerce + Autoptimize
   setup feel free to ask.
 * Thanks,
    Ross
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705856)
 * Thanks for the feedback Ross!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Protocol-less URL support’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/protocol-less-url-support/#post-4705856)
 * Status: resolved