• Resolved vgjustst

    (@vgjustst)


    Hey,

    First of, I think this plugin is great. But I wanted to know/request if a feature is possible.

    Is it possible to exclude certain posts/pages from having the javascript deferred? Right now it is a sitewide solution, but I have noticed that some pages won’t work properly if a Autoptimize is running.

    If it is not possible, please add this feature to exclude post/page ID from being Optimized.

    Looking forward to a reply!

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

    (@futtta)

    that can be done with a couple of lines hooking into AO’s API, as documented in autoptimize_helper.php_example;

    
    add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0);
    function my_ao_noptimize() {
    	if (strpos($_SERVER['REQUEST_URI'],'no-autoptimize-now')!==false) {
    		return true;
    	} else {
    		return false;
    	}
    }

    where no-autoptimize-now is part of the URL (path) of the page to exclude. obviously you can put whatever condition in there ??

    hope this helps,
    frank

    Thread Starter vgjustst

    (@vgjustst)

    Cool thanks for the info!

    Is it possible to separate them by comma?

    I still think this should be a feature in the future so that we can do this from the control panel.

    Plugin Author Frank Goossens

    (@futtta)

    Is it possible to separate them by comma?

    no, you would have to chain conditions, like this;

    
    if ((strpos($_SERVER['REQUEST_URI'],'no-autoptimize-now')!==false) || if (strpos($_SERVER['REQUEST_URI'],'dont-optimize-either')!==false))
    

    I still think this should be a feature in the future so that we can do this from the control panel.

    have a look here instead ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude post/pages from Autoptimize’ is closed to new replies.