Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @manilo23

    Thank you for your inquiry and I am happy to answer.
    Firs I am not really sure what you mean by

    location of the minified file can changes automatically

    The location of the minified files is always the same wp-content/cache/minify/

    Have you tried enabling HTTP/2 push in Performance>Minify>CSS? when enabled it sends files to the browser before they are requested when using the HTTP/2 protocol, meaning the option does what you are trying to do.
    Thanks!

    Thread Starter manilo23

    (@manilo23)

    Hi Marko, thanks!

    The name of the CSS file changes automatically, so i can’t find a way to modify rel=stylesheet to rel=preload.

    Is There a way to modify it? Maybe with a code in functions.php that replace the rel=stylesheet with rel=preload for all CSS file, independently from name that changes.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @manilo23

    Thank you for the information. Just to confirm the names of the minified CSS files do not change automatically. When the files are minified /wp-content/cache/minify/4de8b.css the name 4de8b.css does not change.
    Again what you are trying to do is already available in W3 Total Cache, Performance>Minify>CSS>HTTP/2 push. This option is preloading the minified CSS files.
    Thanks!

    Thread Starter manilo23

    (@manilo23)

    I have HTTP/2 push activeted. But seems that the CSS is still “Render-blocking”.

    I try to add this code to functions.php:

    function add_rel_preload($html, $handle, $href, $media) {

    if (is_admin())
    return $html;

    $html = <<<EOT
    <link rel=’preload’ as=’style’ onload=”this.onload=null;this.rel=’stylesheet'” id=’$handle’ href=’$href’ type=’text/css’ media=’all’ />
    EOT;
    return $html;
    }
    add_filter( ‘style_loader_tag’, ‘add_rel_preload’, 10, 4 );

    In this way, the CSS minified file should be preload. But when i use this code, the minify on W3 Total cache doesn’t work, all file are not “combine&minify”. So i have the original CSS file of my theme and plugin.

    Why W3 Total cache does’t work with this code?

    So i can’t “Eliminate render-blocking CSS“.

    I see that this feature is avaible on Pro. If i buy Pro and after year I do not renew the license, What happen?

    I need only “Eliminate render-blocking CSS” option, i don’t care about all other stuff in the PRO.

    In this way you “force” people to use also Autoptimize for minification, very boring
    ??

    I only need code for Eliminate render-blocking CSS

    • This reply was modified 4 years ago by manilo23.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @manilo23

    First of all, thank you for the clarification. So the point of the question is that you want t to eliminate render-blocking CSS and you are trying to get a workaround to modify minified files to avoid using the Pro feature.
    W3 Total Cache is the most complex Caching plugin and what W3 Total Cache offers for free most of the other plugins are only offering if you are using a paid option.
    Eliminate render-locking CSS by moving it to HTTP body is a Pro feature and yes it’s available only after upgrading the plugin.
    I understand that you don’t care about the other stuff in Pro but again this feature can only be used that way and it would be very unprofessional for me to offer you code for this.

    If i buy Pro and after year I do not renew the license, What happen?

    After the subscription expires and you don’t renew it the Pro features will no longer work.
    THe only solution for this is to use the mentioned option to eliminate render-blocking CSS.
    Thanks!

    Thread Starter manilo23

    (@manilo23)

    Ok Marko, thank you! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add rel=preload to all CSS minified file’ is closed to new replies.