issues with network site
-
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
-
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
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 1hmm, there is a .php ending for the generated JS in other network sites:
autoptimize_96c38aadf0b76905a36562caa0e0f560.phpsite 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 9 years, 2 months ago by
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 9 years, 2 months ago by
cluster666.
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).
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 foldRegards, Ralph
-
This reply was modified 9 years, 2 months ago by
cluster666.
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/autoptimizewith the contents ofautoptimize-masterin 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
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.
Regardsweird .. 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.
Everything works for the main site
The problem only happens with aditional networksites like domain.tld/en/, the main site domain.tld worksIn 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 9 years, 2 months ago by
cluster666.
-
This reply was modified 9 years, 2 months ago by
cluster666.
so 2.1:
* jquery.js is removed on all sites
* jquery code is aggregated in main site’s JS, but not other sitesand 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 siteswhich 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 π
frankmaybe 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?
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
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=1to your URL to see the page un-optimized)?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 sitesdev-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 -
This reply was modified 9 years, 2 months ago by
The topic ‘issues with network site’ is closed to new replies.