• Resolved Anonymous User 14707254

    (@anonymized-14707254)


    First of all I have to say, absolutely wonderful plugin, one of the most useful I have used. Works exactly as it should.

    I’m thinking that this is not currently possible, so maybe it could be an update for the future.

    Autoptimize is optimizing my CSS and my Java script across my site. On only one of my pages, I have a plugin that uses jquery, which affects the loading of the page. If I exclude jquery then it excludes it across my site.

    Currently the only option I have found is to disable Autoptimize on this page using the Plugin Organizer. The result is that all of the CSS on this page is also not optimized.

    If it is possible somehow to exclude jquery from java script optimization for this page only, it would be great.

    Kind regards

    Pace

    https://wordpress.org/plugins/autoptimize/

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

    (@futtta)

    Hi Pace;
    This is possible, using the API and specifically the autoptimize_filter_js_exclude filter:

    add_filter('autoptimize_filter_js_exclude','blupace_jsexclude',10,1);
    function blupace_jsexclude($exclude) {
    	if (strpos($_SERVER['REQUEST_URI'],'/pagenameinurl/')!==false) {
    		return $exclude.", jquery.js";
    	}
    }

    obviously you’d have to change the string in /pagenameinurl/.

    install the code snippets plugin to add this code and you’re good to go.

    hope this helps,
    frank

    Thread Starter Anonymous User 14707254

    (@anonymized-14707254)

    Hey Frank,

    So I have code snippets installed and I can add a snippet,

    This is what I actually need to exclude from Autoptimize:
    jquery,dataTables.responsive, core.js,tables.shortcode

    add_filter('autoptimize_filter_js_exclude','blupace_jsexclude',10,1);
    function blupace_jsexclude($exclude) {
    	if (strpos($_SERVER['REQUEST_URI'],'/blupace.com/links/')!==false) {
    		return $exclude.", jquery.js";
    	}
    }

    Thanks Pace 😮

    Plugin Author Frank Goossens

    (@futtta)

    well, you would add that list of to-be-excluded JS in the return;

    return $exclude."jquery,dataTables.responsive,core.js,tables.shortcode";

    frank

    Thread Starter Anonymous User 14707254

    (@anonymized-14707254)

    Ok got it, thank you so much for your help 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Page specific settings’ is closed to new replies.