• Resolved erictansh

    (@erictansh)


    I am loading bootstrap css before my theme css (custom).

    wp_enqueue_style( ‘bootstrap’ );
    wp_enqueue_style( ‘custom’ );

    The bootstrap is loaded via CDNJS – https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css

    When I enabled Optimize CSS Code,

    My minified CSS code is inserted before the bootstrap CSS, which breaks my site – as some of the theme styles has been superseded by bootstrap default styles.

    Is there any option to choose to insert minified CSS as the last CSS instead of the first?

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

    (@futtta)

    Is there any option to choose to insert minified CSS as the last CSS instead of the first?

    sure; you can use AO’s API to tell it where in the HTML to inject the AO’s CSS (or JS) using code like this one;

    
    add_filter('autoptimize_filter_css_replacetag','erictansh_override_css_replacetag',10,1);
    function erictansh_override_css_replacetag($replacetag) {
    	return array("</head>","before");
    	}
    

    hope this helps,
    frank

    Thread Starter erictansh

    (@erictansh)

    Thanks Frank – work like a charm. Will be checking out your critical css addon soon ??

    Plugin Author Frank Goossens

    (@futtta)

    nice eric ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load autoptimize CSS after bootstrap’ is closed to new replies.