• Resolved vollcom

    (@vollcom)


    Hi, your plugin in very nice … but is there a code like this

    
    <!-- Change Position of JS and CSS -->	
    <!-- WP-Minify CSS -->	
    <!-- WP-Minify JS -->
    

    to change the position on the head?

    Regards

    • This topic was modified 3 years, 2 months ago by vollcom.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    yes, but you’ll need to tell AO about those, e.g. with a code snippet like this one;

    add_filter( 'autoptimize_filter_css_replacetag', 'ao_css_replacetag', 10, 1 );
    function my_ao_override_css_replacetag( $replacetag ) {
    	return array( '<!-- WP-Minify CSS -->', 'replace' );
    	}
    
    add_filter( 'autoptimize_filter_js_replacetag', 'ao_js_replacetag', 10, 1 );
    function my_ao_override_js_replacetag( $replacetag ) {
            return array( '<!-- WP-Minify JS -->', 'replace' );
            }

    You will obviously have to make sure <!-- WP-Minify JS --> and <!-- WP-Minify CSS --> are present in your theme’s template files.

    hope this helps,
    frank

    Thread Starter vollcom

    (@vollcom)

    Hi frank … thx for you replay but your solution is not working … 🙁

    Can you help me again? PLZ 🙂

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    sure, can you explain exactly what you did vollcom ?

    Thread Starter vollcom

    (@vollcom)

    Hi …
    56867#0: *4668519 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback, function "ao_js_replacetag" not found or invalid function name in

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    ah, a typo in my code snippet, stupid me .. try this;

    
    add_filter( 'autoptimize_filter_css_replacetag', 'ao_css_replacetag', 10, 1 );
    function ao_css_replacetag( $replacetag ) {
    	return array( '<!-- WP-Minify CSS -->', 'replace' );
    	}
    
    add_filter( 'autoptimize_filter_js_replacetag', 'ao_js_replacetag', 10, 1 );
    function ao_js_replacetag( $replacetag ) {
            return array( '<!-- WP-Minify JS -->', 'replace' );
            }
    Thread Starter vollcom

    (@vollcom)

    yes thx 🙂 I found also the little mistake but is also not working, because this

    
    <!-- WP-Minify CSS -->	
    

    is an HTML comment.

    I added this in theme’s template file:
    <meta name=”minify” content=”css”>
    <meta name=”minify” content=”js”>

    and this in the function.php:

    add_filter( 'autoptimize_filter_css_replacetag', 'my_ao_override_css_replacetag', 10, 1 );
    function my_ao_override_css_replacetag( $replacetag ) {
    	return array( '<meta name="minify" content="css">', 'replace' );
    }
    
    add_filter( 'autoptimize_filter_js_replacetag', 'my_ao_override_js_replacetag', 10, 1 );
    function my_ao_override_js_replacetag( $replacetag ) {
            return array( '<meta name="minify" content="js">', 'replace' );
    }

    THX 🙂

    now ist working

    • This reply was modified 3 years, 2 months ago by vollcom.
    • This reply was modified 3 years, 2 months ago by vollcom.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    It _should_ work on HTML comments (as AO does the replacing before removing comments), but whatever the problem was happy it now works for you vollcom 🙂

    feel free to leave a review of the plugin and support here! 🙂

    have a nice day!
    frank

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change position CSS/JS in the head’ is closed to new replies.