Support » Plugin: Autoptimize » Script dependencies are not working properly

  • I have my main JS file that being enqueued on all pages:
    wp_enqueue_script('mainscript', get_template_directory_uri() . '/assets/js/theme-script.js');

    Also I have a few scripts, that appear only on one page:

    if (is_page('about')) {
        wp_enqueue_script('typed', get_template_directory_uri() . '/assets/js/typed.min.js', ['mainscript'], '', true);
        wp_enqueue_script('about-page', get_template_directory_uri() . '/assets/js/pages/about.js', ['typed'], '', true);

    As you can see, I add “mainscript” as dependency to my “about page” scripts. Also, I excluded these scripts from being optimized in AutoOptimize settings (I want them to be loaded in separated file/files).

    But “about scripts” load before main script cache file. What can I do to fix this?

    p.s. when I logged as admin (and my files are not optimized) – it works fine.

Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Script dependencies are not working properly’ is closed to new replies.