Comments (5)
Well, filename is autoptimize_.js (see classes/autoptimizeScripts.php), so that means there have to be (minor) differences between those files. This is typically caused by plugins inserting small pieces of page- (or request-)specific inline code. As inline code is aggregated by default, this has as a consequence that a huge amount of files are being created.
There are 2 solutions for this problem:
- finding the the offending JS-code and exclude that from being aggregated (see FAQ)
- disabling aggregation of inline JS as a whole, which can be done using the API as seen in autoptimize_helper.php_example
For AO 2.0 I will most probably make "aggregate inline JS" (and CSS) an option in the settings-page (which will be off by default, to avoid people running into this particular issue).
Concerning autoptimize_cache_nogzip is the option used to store the setting if autoptimize JS/ CSS is to be delivered statically (true) or dynamically (false), this logic is in classes/autoptimizeCache.php.
Hope this clarifies :-)
frank
from autoptimize.
thanks @futtta, and sorry for the noise.
i'll try to find out why my compare of the files shows them as identical, but obviously the live code is not. It's got to be something simple
from autoptimize.
For AO 2.0 I will most probably make "aggregate inline JS" (and CSS) an option in the
settings-page (which will be off by default, to avoid people running into this particular issue).
@futtta I have tweaked some of the plugins I use to put a well known class attribute on scripts that I don't wan't moved out of the code. Most of these tend to be the CDATA only scripts that get created as a result of wp_localize_script.
If you are thinking about providing some additional options around what to localize, perhaps a "don't localize CDATA only scripts " option would be useful. These scripts don't seem to impact page speed scores, not sure about if the browsers are tagging these as blocking or not?
from autoptimize.
hiya @JeffPyeBrook;
Generally speaking CDATA-blocks are actually leftovers from the XHTML-days to identify parts of the XML-tree that was to be excluded from XML-parsing. As such any inline JS could be blocking or non-blocking, depending on what the JS is doing. Just setting some variables would be non-blocking, but doing some heavy lifting (and e.g. connecting to 3rd parties) would clearly be blocking, no matter if the JS was enclosed in CDATA-markers or not.
Now specifically for WP-scripts; it indeed seems that WP core inserts CDATA-markers when doing wp_localize_script (as per print_extra_script() in wp-includes/class.wp-scripts.php, which mentions CDATA is not needed, so it might get dropped anyhow).
Conclusion: I'm not sure it's a good idea to to rely on that in AO-core But one could simply add "CDATA" to AO's JS exclusion-list if one wanted to, no?
from autoptimize.
@futtta Yes, I also experimented with adding the CDATA to the exclusion list and everything that you would expect to was skipped, but ended up adding the class attribute to the plugins to get better control. It was necessary because I wanted to ensure some scripts with CDATA were parsed prior to other javascript. Specifically, AdWords and Google Analytics scripts.
from autoptimize.
Related Issues (20)
- Make compatibility configurable HOT 8
- Compatible wih WP 6 and PHP 8.1 HOT 1
- Keep the code base clean HOT 3
- Undefined offset autoptimizeStyles.php HOT 3
- autoptimizecriticalcsscron PHP array key warnings HOT 5
- Avif support broken HOT 6
- Minified JS broken with private class identifiers HOT 4
- Disable emoji dns-prefetch in ClassicPress HOT 1
- PHP8 Warning HOT 1
- Optimized JS and inline script order HOT 3
- Problem with media="print" HOT 3
- Inline "background" not replaced with shortpixel HOT 5
- Security risk reported by Kaspersky HOT 6
- Proposal: stronger default settings HOT 9
- Optimised Google Fonts still blocking for 1.3s according to PageSpeed HOT 2
- Add: option to enable WebP as default output format HOT 1
- PHP Warning in cronjob: Trying to access array offset on value of type int in autoptimizeCacheChecker.php HOT 3
- Creation of dynamic property in autoptimizeProTab.php HOT 4
- Proposal: add Plugin Check workflow HOT 6
- Autoptimize deletes all subfolders in /cache/ HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autoptimize.