• I have a multisite and use “optimize JS” only nothing else.
    CSS has been manually integrated inline …
    The main site works with Autoptimize but the other languages do not work correctly. I have a fixed Header and I guess that the different JS location does not work with my inline css for the other languages …
    If I disable Autoptimize, it works and the header is not broken.
    Is there a way to use the same JS file from the main page (1) for all networksites perhaps a hack in functions.php?

    Regards, Ralph

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

    (@futtta)

    can you describe into some detail what you mean with “the other languages do not work correctly”? is the JS not optimized at all? is it optimized but does it throw errors? how is “inline CSS” relevant if you’re not optimizing CSS?

    (there’s no way to enforce AO’d JS from site1 to be reused on other sites that I can think of)

    frank

    Thread Starter cluster666

    (@cluster666)

    Hi Frank,
    for all sites: Autoptimize settings > JavaScript-Options > just optimize JS is activated nothing else.
    Site 1 works with Autoptimize activated – the other network sites (3 languages) shows a broken Header and Navmenu.
    The JS file is generated and in place but it seems it work only with site 1

    Thread Starter cluster666

    (@cluster666)

    hmm, there is a .php ending for the generated JS in other network sites:
    autoptimize_96c38aadf0b76905a36562caa0e0f560.php

    site 1

    
    <script type="text/javascript" defer src="https://www.mysite.tld/media/cache/autoptimize/1/js/autoptimize_1cc3d6828026d05e687f4edffe98511b.js"></script>

    site 2

    
    <script type="text/javascript" defer src="https://www.mysite.tld/media/cache/autoptimize/2/autoptimize_96c38aadf0b76905a36562caa0e0f560.php"></script>

    edit
    sorry, I had disabled static files but same issue w/ enabled

    • This reply was modified 7 years, 8 months ago by cluster666.
    Thread Starter cluster666

    (@cluster666)

    some more details, the generated .js have different filesizes …
    If I copy the contents from JS 1 into JS 2 it works
    It seems the jquery part is missing for the other network sites:
    /*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */
    ……

    • This reply was modified 7 years, 8 months ago by cluster666.
    Plugin Author Frank Goossens

    (@futtta)

    and how are you setting your sub-sites AO config? because the .js vs .php stuff is pure AO config (last option; “static delivery” which is on by default).

    Thread Starter cluster666

    (@cluster666)

    yep, it seems jquery is not included by autoptimize for the other network sites …
    It works only for the main site.
    If I add jquery.js to the autoptimize JS filter list it works but jquery is still included above the fold

    Regards, Ralph

    • This reply was modified 7 years, 8 months ago by cluster666.
    Plugin Author Frank Goossens

    (@futtta)

    well, you might want to give AO’s in-development version a try: it has some significant improvements in the logic of what can (not) be autoptimized and might automagically fix the issue of the vanishing jquery.js. you can download the zip here, simply overwrite wp-content/plugins/autoptimize with the contents of autoptimize-master in the zip.

    (small warning; there’s an open bug in the data-uri-generation for background-images logic on the dev-version, so maybe be careful if you use that feature)

    frank

    Thread Starter cluster666

    (@cluster666)

    thanks Frank, it’s still ignored for the network sites only the generated .JS file for the main site contains the jquery part …
    so I guess for now I need to copy the content from the working JS file to the others.
    Regards

    Plugin Author Frank Goossens

    (@futtta)

    weird .. can you give me some links so I can have a look?

    the problem with you workaround is that as soon as there’s the smallest change in the aggregated JS for the sub-sites, the JS will be re-created and jquery will again be missing.

    Thread Starter cluster666

    (@cluster666)

    Everything works for the main site
    The problem only happens with aditional networksites like domain.tld/en/, the main site domain.tld works

    In Version 2.10 release (not master) this js part is removed correctly:
    <script type='text/javascript' src='https://www.mydomain.tld/en/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>

    but jquery part is missing in generated .JS (only for the further networksites /en/, /fr/ …)

    With the files from Master this part is not removed and also jquery is not placed into the generated JS file (only for further network sites)
    <script type='text/javascript' src='https://www.mydomain.tld/en/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>

    • This reply was modified 7 years, 8 months ago by cluster666.
    • This reply was modified 7 years, 8 months ago by cluster666.
    Plugin Author Frank Goossens

    (@futtta)

    so 2.1:
    * jquery.js is removed on all sites
    * jquery code is aggregated in main site’s JS, but not other sites

    and dev-version:
    * jquery.js is removed on main site but not on other sites
    * jquery code is aggregated on main site, but not on other sites

    which means that in the dev-version nothing is broken, it’s just that you don’t like jquery.js is not aggregated, right?

    if the above is correct; the problem is that AO takes the script URL and “translates” it into the filesystem path, using the wp-content-url and site_url as a basis. in the dev-version logic was added to only remove links tot JS (or CSS) files if the path to the file can be read due to the path being wrong. the fact that the path is wrong is probably due to a difference between site_url and/or wp-content-url and the URL to the script in the output.

    now if this is confirmed, you could hook into AO’s API to fix this (i.e. to make sure the url->path translation works taking your context into account).

    hope this clarifies somewhat ??
    frank

    Thread Starter cluster666

    (@cluster666)

    maybe it could be solved by override the enqueue parts for the networksites (site 2, 3, 4) should use the JS output or file from site 1?

    Thread Starter cluster666

    (@cluster666)

    thank you!
    OK, I understand but how do I set a hook for using site_url or wp-content-url … could you please post an example?

    Regards, Ralph

    Plugin Author Frank Goossens

    (@futtta)

    well, let’s take a step back first. as all JS except jquery.js is aggregated correctly, what is the path to jquery.js vs jquery-migrate.min.js (or any other aggregated js-file) if AO isn’t active (you can add ?ao_noptimize=1 to your URL to see the page un-optimized)?

    Thread Starter cluster666

    (@cluster666)

    OK, I’ve tried with a hardcoded jquery in the header and variables for network_url, it shows the same result as above.

    I have checked the link from sourcecode before AO was activated!
    $langlink means “/en” “/fr” when change the languages
    <script type='text/javascript' src='<?php echo network_site_url(); ?><?php echo $langlink; ?>wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>

    2.1:
    * jquery.js is removed on all sites
    * jquery code is aggregated in main site’s JS, but not other sites

    dev-version:
    * jquery.js is removed on main site but not on other sites
    * jquery code is aggregated on main site, but not on other sites

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘issues with network site’ is closed to new replies.