Code Monkey home page Code Monkey logo

autoptimize's People

Contributors

adamsilverstein avatar akkspros avatar asadkn avatar chesio avatar crbrz avatar dtbaker avatar eri-trabiccolo avatar futtta avatar gonzomir avatar harrymilatz avatar jeffpyebrook avatar kovshenin avatar kraftpixel avatar luboshilgert avatar macbookandrew avatar mehigh avatar nextend avatar pedro-mendonca avatar phc369 avatar pierlon avatar presskopp avatar rodrigo-arias avatar samitrimal avatar shakee93 avatar sjoerdlinders avatar szepeviktor avatar viktorix avatar westonruter avatar wvega avatar zytzagoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autoptimize's Issues

Content-Security-Policy

Is there a way that Autooptimize could insert a script/css 'nonce' in the script/style tag, that way I could allow scripts and css with that nonce while disallowing all others (and abandoning 'unsafe-inline').

Autooptimize is the perfect place for this feature because it already can strip all inline code, it's just missing a function to either generate a script/css hash and modifying the csp header or alternatively just adding the tag required above.

CSS/JS filters test report

@futtta,

CSS filters works great in any case I tested.

add_filter('autoptimize_filter_css_removables','fgo_css_remove',10,0);
function fgo_css_remove() {
  return "font-awesome.css, ut-superfish, ssbp, wp-content/themes/brooklyn-child/css/custom.min.css";
}

In the other hand, no JS exclusions have worked as expected.

add_filter('autoptimize_filter_js_removables','fgo_js_remove',10,0);
function fgo_js_remove() {
  return "jquery.js, jquery-migrate.js, emoji, superfish.min.js, ssbp_page";
}

The theme I use heavily depends on jQuery. I know the exclusion do not work because jQuery code is in the optimized JS created by AO after the filter is in place and because the site still works.

Fatal error optimizing styles

Woke up this morning to a site that is down , and an error log that is full of these messages.

[12-Jan-2016 06:26:22 America/New_York] PHP Warning: preg_match_all(): Compilation failed: range out of order in character class at offset 68 in /wp-content/plugins/autoptimize/classes/autoptimizeStyles.php on line 401

Adding TOC

What are the steps?

  1. Record TOC items in foreach($this->css as $group)
  2. Prepend TOC in $cache->cache($code,'text/css');
  3. Add an option?

Sorry. I am not familiar with AO.

Improve treatment of jQuery as "special citizen"

Hey @futtta - we all know and love how jQuery needs to stay in the header to stay compatible with plugins, templates, etc.

Seeing that the optimised CSS and JS use deferred loading by default, I suggest recognising the special role jquery has by giving it it's own setting, e.g.:

  • Enable deferred jQuery in header, or
  • Exclude jQuery from Autoptimize and make it deferred instead

Which (if enabled) excludes it, but instead sets the "defer" attribute when found in the page.

I'm kind of hesitant on installing yet another plugin just to make one script deferred if Autoptimize is handling everything else without issue.

EDIT: Nevermind - upon further testing I haven't been able to make even a deferred jQuery behave properly with some Jetpack modules (InfiniteScroll adds inline code depending on jQuery being loaded without Autoptimize being able to grab it even with enabled aggregation of inline JS).

Consider this issue "invalid".

JavaScript default improvements.

Oops published too early.

Basically, I propose that jquery.js is added to the default ignore list since minifying and moving it to the footer will break most sites, and it ships optimized from core already. You will get more performance moving the rest of the scripts to the footer while ignoring Jquery then you would from moving them all to the header.

Therefore, I propose the default options in JS are moved to ignoring jquery.js and to uncheck the force JS in head.

Most sites won't have any problems with this configuration and people will get a larger performance boost this way.

log alerts for unreadable CSS

When developing an asset may be unavailable.
If autoptimize is off, a 404 is triggered that helps spotting the problem.
But is autoptimize is on, CSS content is simply dropped which lead to a partial compressed CSS without notification. This could be misleading.

Autoptimze mess up CSS and JS

Hello,

I wiped my autoptimize cache today and my website is not displaying properly :

screenshot_27-01-2016_jqohofmo
instead of :
screenshot_27-01-2016_qh5vtggv

I do not have any HTTP erros like 404 so I don't understand. All my CSS and JS are in the 2 files as always.

HTTP2 Push Header - Feature Suggestion

Hey, @futtta . Celso Bessa, AO pt-br translator here.

As you know, HTTP2 push is a big deal in optimization now. We are getting great results in some of our projects with it and I think it would be great if AO included a mechanism to use those headers.

In some test setups we filtered AO final JS/CSS srcs and created our own headers using PHP/WP send headers ( https://codex.wordpress.org/Plugin_API/Action_Reference/send_headers ). this is not hard for us, but it might be not easy for an non technical user.

In other setups we used AO alongside http2 server push plugin by @daveros ), which is great, but it sends headers for all files in the original wp_enqueue queue but not for AO aggregated files (my guess is it uses a hook triggered before AO).

Looking this 2 cases, seems to me that having this on AO would help a lot of you user base.

What do you think? I won't be able to code anything for the next 4 weeks, but if you think it's a good feature, I can work on this in august.

Allow to put inline CSS after HTML

This is a easy way to fix "prioritize visible content", I guess, instead of all the work of critical CSS. I'm having problems messing on a site made by thirds where I can't upgrade my PageSpeed score due to the huge chunk of CSS generated and put after HTML, or (I'm not sure) some problem with PageSpeed's parse and "CSS inline and defer".
What do you think?

remove source maps from comined CSS

When building CSS from something like SASS or LESS, or even combining multiple CSS files together with PostCSS, it's common to generate a source map file. This allows browser debuggers to link back to the source file/line, e.g. when doing an Inspect Element. The source map is often (perhaps typically) linked from the generated CSS file inside a comment, like this:

/*# sourceMappingURL=style.min.css.map */

When Autoptimize combines CSS into one file in the Autoptimize cache folder, such relative references break. The browser still tries to load the file when the debugger is open, but it tries to find it within the Autoptimize folder:

/wp-content/cache/autoptimize/nnn/css/style.min.css.map

That translates into a WordPress page render (or cache load). It's unnecessary, because anyone wanting to debug their CSS will just turn Autoptimize off while they do that.

I reckon you could happily ditch any source map references in your combined CSS files, because they simply won't be of any use and can generate extra browser fetches when visitors have their debugger open. Removing these references will also squeeze a few more bytes from the combined CSS files :)

Background image data:... URI replacement mistakenly replaces some rulesets and breaks CSS

Hi there,

First off, thank you for the amazing plugin – it's worked flawlessly for me until just recently! :)

On one of my sites, I use the class .has-background for certain elements, and I discovered yesterday that if I turned on the "Generate data: URIs for images" setting in Autoptimize, parts of my CSS would get mangled.

I finally tracked this behavior down to the regex on line 299 of classes/autoptimizeStyles.php: it will actually try to replace certain selectors that include the word "background," as long as they're followed somewhere by url(...).

For example, given this CSS:

.has-background { background: url(images/bg.png); }

Autoptimize will attempt to replace background { background: url(images/bg.png) instead of just background: url(images.bg.png). Thus the replacement adds multiple unmatched {s, breaking all CSS rules further down in the file.

I've found a really simple fix that addresses my particular use case, and I'm about to submit a pull request, but I'd appreciate any feedback – maybe there's a good reason for the original regex not to skip over matches containing a {.

multiple userSettings values => multiple autoptimize files

Hi, I've a lot of "autoptimize_*.js" files created
Here is a diff between the two last:

< var userSettings={"url":"\/","uid":"11","time":"1475152253","secure":"1"}

---
> var userSettings={"url":"\/","uid":"58","time":"1475152415","secure":"1"}
33952c33952
<  https://xxx/wp-content/plugins/wp-columna/style.css?bogus=1475152253"

---
>  https://xxx/wp-content/plugins/wp-columna/style.css?bogus=1475152415"

Aside from the plugin (which, I guess should be fixed to avoid aggregation), the userSettings comes from core.
I'd not expect it from being aggregated and thus multiply the number of files created by autoptimize.

Load external dependencies before the optimized script

Hi,

I have a WordPress plugin that includes JavaScript code that depends on external libraries loaded from a CDN:

  • Both the plugin's code and the external library are registered with wp_register_script.
  • The external library is listed as a dependency of the plugin's code.
  • Both scripts are configured to be printed in the footer.

Without Autoptimize, WordPress prints the the <script> tags in the necessary order: the external library appears first, then the plugin's code.

With Autoptimize, the optimized script that includes the plugin's code is printed in the page's <head> (because the Force JavaScript in <head>? setting is enabled), but the external library is still printed before the </body>. As you may expect, this causes the the plugin's code to start throwing errors because the external library is not defined.

I noticed that disabling Force JavaScript in <head>? fixes the problem, and that maybe the solution for my user's problem. However, I still have a question:

Is it possible to have Autoptimize move the external library to the <head> as well, whenever the Force JavaScript in <head>? setting is enabled AND one of the optimized scripts has a dependency on that library?

strange behaviour

Hey there,
currently I'm working with autoptimize development version and came across some unusual behaviour the other day: the files are being generated, but not referenced in the html output. I already checked file permissions, but nothing even with 777. maybe a bug? Happens both with and without page caching plugin (in my case Cachify).

Thanks for this great plugin and your time,
S1SYPHOS

E_NOTICE Undefined property: autoptimizeStyles::$already_minified

Hey there, Autoptimize is one of the best minifcation/concatetation plugins I've found - works a charm but I got this PHP Notice, perhaps you could check it out (the [XXXXXXX] is just the path to a server which I edited out)

E_NOTICE  Undefined property: autoptimizeStyles::$already_minified -     
[XXXXXXX]/app/plugins/autoptimize/classes/autoptimizeStyles.php:329 
#7 [XXXXXXX]/app/plugins/autoptimize/autoptimize.php:265 - autoptimizeStyles->minify()
#6 [internal call] - autoptimize_end_buffering('<!DOCTYPE html...', 5)
#5 [XXXXXXX]/wp-includes/functions.php:3269 - ob_end_flush()
#4 [internal call] - wp_ob_end_flush_all('')
#3 [XXXXXXX]/pigafetta/wp-includes/plugin.php:496 - call_user_func_array('wp_ob_end_flus...',    Array[1])
#2 [XXXXXXX]/wp-includes/load.php:613 - do_action('shutdown')
#1 [internal call] - shutdown_action_hook()
[XXXXXXX] Failed to load resource: net::ERR_CACHE_MISS

Enabling HTML optimization strips <!CDATA comments from inline JavaScript

Greetings, reporting from WP 4.6.1 & autoptimize 2.1.0 operating in tandem with WP super cache.

In short: CDATA is removed from the inline javascript fields upon html optimization being turned on. This removal happens. Even if every other optimization (JS & CSS) is disabled completely. This removal is not effected by: "Keep html comments", Exclude scripts from Autoptimize, or Exclude CSS options. The only way to prevent CDATA from being removed is by adding tag to the code.

This removal effects things like Google Conversion tracking javascript. Which functions in following format. It is also noteworthy that despite adding the google_conversion_id to exclusion list, the cdata comments will still disappear.

/* <![CDATA[ */
var google_conversion_id = 000000000;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "AVCDEFGHIJ25LMN";
var google_remarketing_only = false;
/* ]]> */

The issue effects Autoptimize's own variable autoptimize_ajax_object (Warning about cache might not have been purged successfully inserted into html source)

As well as effecting Disqus comment system variable countVars which contains disqusShortname

While most browsers manage work without the CDATA information Google has stated the following: "While most browsers can properly render the AdWords Remarketing snippet in the absence of CDATA comments, other browsers will fail to properly execute the script. This will result in conversions under-reporting."
Source

Cheers and have a nice day.

Changing prefix and folder not working.

If i try to change the served filenames as described in your FAQ with the following commands:

define('AUTOPTIMIZE_CACHE_CHILD_DIR','/resources/');
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_');

The files still are named autoptimize_ ... further wordpress gives me the following errors:

Notice: Constant AUTOPTIMIZE_CACHE_CHILD_DIR already defined in /var/www/virtual/rcws/html/wordpress/wp-config.php on line 133

Notice: Constant AUTOPTIMIZE_CACHEFILE_PREFIX already defined in /var/www/virtual/rcws/html/wordpress/wp-config.php on line 134

Use whitelist instead of blacklist for CSS/JS optimization

It would be great if there were an alternate method for deciding what gets optimized that used a whitelist instead of a blacklist. This would come in especially handy with complex sites where coming up with a list of JS/CSS that can be safely optimized is much easier than a list of all the stuff that can't.

toolbar; honour admin css styles (colors)

got this remark from a tester;

The Red icon does not show on the Sunrise admin color scheme. In general, the color of the icon should be aware of the admin color scheme so it can contrast.

if you have any idea how to do that @pablocusto , "go"! ;-)

But I consider this minor, really (the timeout is way more important).

HTTP/HTTPS issue causing security warnings

having a little issue, it's reproducible, but I can't seem to track down the cause

Do this ...

  1. Set inline all css
  2. Set a cdn url to use for css images
  3. Put relative urls in style sheets a couple levels deep in the wordpress directory tree ( wp-content/plugin-name/css/style.css )
  4. serve the page over https,

The relative urls are turned into full paths, but start with 'http://' rather than 'https://' or '//'.

This causes the browser to show the security warnings rather than the good https icon

toolbar; division by zero on line 56

While testing I all of a sudden got this @pablocusto;

Warning: Division by zero in /var/www/futtta.be/wordpress/wp-content/plugins/autoptimize/classes/autoptimizeToolbar.php on line 56
Notice: Undefined offset: -2147483648 in /var/www/futtta.be/wordpress/wp-content/plugins/autoptimize/classes/autoptimizeToolbar.php on line 56

Not sure I understand what's happening, but I'm sure you do? :-)

Multisite Subdir / Combine Issue

Hi @futtta

Main site has been combine well but same domain subdir multisite (same theme, same plugins, same settings) hasn't properly combine / just one css combine file & js combine file but other css & js still viewing in code.

Piece of head output;

`

<title>Home « Example - EN</title> <script type="text/javascript">window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"https:\/\/example.com\/en\/wp-includes\/js\/wp-emoji-release.min.js"}};
        !function(a,b,c){function d(a){var c,d=b.createElement("canvas"),e=d.getContext&&d.getContext("2d"),f=String.fromCharCode;return e&&e.fillText?(e.textBaseline="top",e.font="600 32px Arial","flag"===a?(e.fillText(f(55356,56806,55356,56826),0,0),d.toDataURL().length>3e3):"diversity"===a?(e.fillText(f(55356,57221),0,0),c=e.getImageData(16,16,1,1).data.toString(),e.fillText(f(55356,57221,55356,57343),0,0),c!==e.getImageData(16,16,1,1).data.toString()):("simple"===a?e.fillText(f(55357,56835),0,0):e.fillText(f(55356,57135),0,0),0!==e.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g;c.supports={simple:d("simple"),flag:d("flag"),unicode8:d("unicode8"),diversity:d("diversity")},c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.simple&&c.supports.flag&&c.supports.unicode8&&c.supports.diversity||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);</script> <style type="text/css">img.wp-smiley,

img.emoji {
display: inline !important;
border: none !important;
box-shadow: none !important;
height: 1em !important;
width: 1em !important;
margin: 0 .07em !important;
vertical-align: -0.1em !important;
background: none !important;
padding: 0 !important;
}</style><script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script> <script type='text/javascript'>try{jQuery.noConflict();}catch(e){};</script> <script type='text/javascript' src='https://example.com/plugins/ultimate-tweaker/sections/content/content_link_target_blank/post-link-target-blank.min.js'></script> <script type='text/javascript' src='https://example.com/plugins/inventor/libraries/cmb_field_map/js/script.js'></script> <script type='text/javascript' src='https://example.com/plugins/inventor/libraries/cmb_field_street_view/js/script.js'></script> <script type='text/javascript' src='//maps.googleapis.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXXXXXXX;libraries=weather%2Cgeometry%2Cvisualization%2Cplaces%2Cdrawing'></script> <script type='text/javascript'>/* /
var userSettings = {"url":"/","uid":"161028","time":"1458575218","secure":"1"};
/
*/</script> <script type='text/javascript' src='https://example.com/en/wp-includes/js/plupload/plupload.full.min.js'></script> <script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'></script> <style>.getty.alignleft {
margin-right: 5px;
}
.getty.alignright {
margin-left: 5px;
}</style> <script type="text/javascript">var essb_settings = {"ajax_url":"https://example.com/en/wp-admin/admin-ajax.php","essb3_nonce":"f185240593","essb3_plugin_url":"https://example.com/plugins/easy-social-share-buttons3","essb3_facebook_total":true,"essb3_admin_ajax":true,"essb3_internal_counter":false,"essb3_stats":true,"essb3_ga":true,"essb3_ga_mode":"extended","essb3_counter_button_min":50,"essb3_counter_total_min":500,"blog_url":"https://example.com/en/","ajax_type":"light","essb3_postfloat_stay":false,"essb3_no_counter_mailprint":true,"essb3_single_ajax":true,"twitter_counter":"api","post_id":521};</script>`

`register_uninstall_hook()` called on every page load results into multiple unnecessary database queries

In the end of the main plugin file, autoptimize.php, register_uninstall_hook() is called every time the plugin loads. This results into two SELECTs and one UPDATE on every page load.

While the queries are not very expensive they are unnecessary. Eliminating the queries halves the database query time on my blog from 40 milliseconds to 20 ms.

The easiest way to fix this would be to wrap the call to register_uninstall_hook() like this:

function autoptimize_activate(){
    register_uninstall_hook( __FILE__, 'autoptimize_uninstall' );
}
register_activation_hook( __FILE__, 'autoptimize_activate' );

This way the uninstall hook would only be registered once, not on every page load.

Disk space used by cache growing too large

Ran into an issue on a couple of sites where the javascript cache is growing many gigabytes too large. Looking at the cached files there are a couple things I noticed.

Many of the files have identical contents. Is there any way we can have the optimizer use the file contents to create the file name hash? This would stop the data duplication.

If it is the case we need to know the filename where the collected and minified javascript is being stored very early in the page generation process perhaps we could create the file name as we are doing now but use a link to connect it to the file data?

I also noticed the option autoptimize_cache_nogzip in the code but couldn't find documentation on how the zip functionality might be used to save disk space?

Autoptimize incompatible with diverting CDN paths

Not necessarily a bug, more a peculiarity I've found when I configured my WP install to use a CDN url for all external assets:

  • Both Autoptimize as well as my CDN plugin were configured to use the same URL/host (cdn.mydomain.com)
  • The wp-content and wp-include folders were mirrored at a subdirectory of that host (https://cdn.mydomain.com/blog/...)
  • The CDN plugin took a full path so that config worked out of the box
  • Autoptimize only takes a hostname

This leads to the situation where the scripts/stylesheets hosted on the CDN are recognised by the plugin out of the box (due to the CDN host being configured), but as they are on a different path, it can't open them locally.

Example:

  • CDN path: http://cdn.mydomain.com/blog/wp-content/theme/styles.css
  • Real path: http://www.mydomain.com/wp-content/theme/styles.css

The plugin fails to concat all the files (even though it tries to) and thus empty stylesheets/scripts are generated.

The following snippet in my functions.php fixed the issue, but would be great if the CDN path could be recognised by the "domain" setting:

function ao_fix_uri($uri) {
    return str_replace("/blog/wp-", "/wp-", $uri);
}

add_filter('autoptimize_filter_cssjs_alter_url', 'ao_fix_uri');

Use WP Content URL instead of Site URL

After installing this plugin we found that the CDN URL feature wasn't working. After further investigation it seems pretty clear that you're performing a search and replace using the site_url, instead of the content_url.

https://github.com/futtta/autoptimize/blob/52c73d85/classes/autoptimizeBase.php#L184

See Wordpress Codex - Editing WP-Config.

I can see that themes themselves even use functions like get_template_directory_uri or get_stylesheet_uri.

It appears that these functions make use of get_theme_root_uri, which itself depends on the WP_CONTENT_DIR constant as a primary before trying WP_PLUGIN_DIR.

Change wp-content dir to other host

Hi
First of all, thx for your job.
Well, I tryed to change wp-content to other vhost.
I put
define('WP_CONTENT_DIR','new/path/wp-content');
define('WP_CONTENT_URL','https://vhost/wp-content'):
in wp-config.php, with and w/o set 'https://vhost' at cdn field in autoptimize config.
No file where created unless an empty /new/path/wp-content/cache/autoptimize/js/autoptimize_XXXX.js.
If these file is created, no file permision issue here. All css and js files from wp-include, theme and plugins are downloaded from https://vhost correctly. Seems the AO don´t cacht these files to do their work (unify and minify). No error in logs nor display.
Some clue to debug this?
Thx in advance

How about embedding small images in img's src?

My website has logos which are about ~2.5k each. They currently are fetched as any other regular image. Sounds like I could spare two calls to my servers in every single page by embedding these two images. Do you think Autopitmize can do that (like it does for CSS background images)?

Gzip output not used.

Hi Frank,

Your plugin now supports creation of pre-gzipped files. I have enabled them using:

add_filter('autoptimize_filter_cache_create_static_gzip','__return_true');

However this file doesn't seem to be used and the server is gzipping everytime. My conclusion is based on the observation that the content-length as seen from Chrome development tools is higher than the static gzip file.

I think you need to add headers in htaccess asking the server to use the gzip file instead of dynamically compressing.

Code here

<IfModule mod_headers.c>
    # Serve gzip compressed CSS files if they exist 
    # and the client accepts gzip.
    RewriteCond "%{HTTP:Accept-encoding}" "gzip"
    RewriteCond "%{REQUEST_FILENAME}\.gz" -s
    RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA]

    # Serve gzip compressed JS files if they exist 
    # and the client accepts gzip.
    RewriteCond "%{HTTP:Accept-encoding}" "gzip"
    RewriteCond "%{REQUEST_FILENAME}\.gz" -s
    RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]


    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
    RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]


    <FilesMatch "(\.js\.gz|\.css\.gz)$">
      # Serve correct encoding type.
      Header append Content-Encoding gzip

      # Force proxies to cache gzipped & 
      # non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
</IfModule>

use of standards WP hooks rather than output buffering

I looked at the code and found that most of it is executed inside an output buffering handler.

I would like to know:

  • why was it done like this?
  • don't recent WP version help streamlining the process?
  • why not simply use WP hooks in order to fetch every queued js/css rather than regexp over the final HTML?
  • do you know of similar caching plugins hooks standard hooks to achieve the same result? What are their drawback w.r.t to this?

autoptimize scripts is throwing an error minifying js

autoptimize scripts is throwing an error

error type: [8] Undefined variable: input file: ...\wp-content\plugins\autoptimize\classes\external\php\minify-2.1.7-jsmin.php line: 92

Seems to be because the constructor for the JSMin class requires a parameter and none is provided. We probably don't need to create an object of the class since the method is called staticly

Maybe the line

if (@is_callable(array(new JSMin,"minify"))) {

should be rewritten to

if (@is_callable(array( 'JSMin' , 'minify' ) ) ) {

Minified CSS has line breaks

Hi Frank,

Not sure which version this happened but the minified css (both external and inline) have line breaks. Do you know how this may have happened? Has the minifier option changed?

Inline script getting corrupted

This inline script is getting corrupted when minified:
<script type="text/javascript">document.write('<style type="text/css">.tabber{display:none;}<\/style>');</script>
I've had a issue open with the minification library initially, but it seems it might be a issue in the way its used.
mrclay/minify#483

Any thoughts?

Font CSS URL not being set to CDN

Noticed a couple of files not being redirected to come from CDN. The specific case is the fontawsome.css

This is what is in the CSS.

@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=4.3.0');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

Was also wondering if the fixurls function in the autoptimizeStyles class could use the cdn url when set instead of the site url?

poll: does AO 2.0 work for you?

So does Autoptimize 2.0 Beta work (not talking about the current version, 1.9.4) for you?

Please chime in by replying with "OK" (aka :+1:) or "Not OK" (aka :-1:), in which case some extra info would be welcome!

Network settings

I would like to activate for a MU network and apply the settings to all network sites - is this something you could add?

Remove comments from minified css and js for better Page Speed Insights score

Hello futta and all :)

I'm optimizing the pagespeed for a website and autoptimize was a huge time saver here. However Page Speed Insights is still telling me:

Minify CSS for the following resources to reduce their size by 727B (1% reduction).

Those 1% are simply the comments left in the minifed css file, mainly the license comments. Is there an option to remove these comments or are they left in the minifed version on purpose? I could not find any information regarding that yet.

Regards
Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.