Script order after merging scripts

[ad_1]

Aggregating is done long after assets are enqueued and only takes the exclusions (configured and some hardcoded) into account I’m afraid.

So looking at your HTML source, are your own scripts aggregated or do they remain separate?

Aggregated. This part is very well.

Before aggregate like:
<link theme.css>
<link angular.min.css> (external)
<link myscript1.css>
<link myscrip2.css>

After aggregate like:
<link autoptimize_xy.css>
<link angular.min.css>

External: add_filter(‘wp_enqueue_scripts’, [$this, ‘loadScriptsFirst’], 0);
My script: add_filter(‘wp_enqueue_scripts’, [$this, ‘loadScriptsLast’], 100);

aha, an external file, AO indeed cannot aggregate those. what you could to is change the “injection point” for CSS with below code snippet;

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

hope this helps,
frank

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer