• Resolved Pratham

    (@pratham2003)


    I’m trying to revert to the old way of deferring CSS to work with a javascript I had written long ago to further delay the CSS from loading but this is leading to some weird output that looks like a bug because there are two link tags being output (excluding the one inside the noscript tag)

    My filters

    
    add_filter('autoptimize_filter_css_preload_onload', function() {
    	return "this.onload=null;this.setAttribute('data-loaded', '1');";
    }, 10, 0);
    
    add_filter('autoptimize_fitler_css_preload_and_print', '__return_true');
    
    
    <link rel="preload" as="stylesheet" href="https://example.test/wp-content/uploads/elementor/css/post-5.css" /><noscript><link rel='stylesheet'  href='https://example.test/wp-content/cache/autoptimize/css/autoptimize_single_310a89fd1e8dc24a98b01a7ed7500698.css?ver=1616678114' media='all' /></noscript><link rel='stylesheet' id='elementor-post-5-css' href='https://example.test/wp-content/cache/autoptimize/css/autoptimize_single_310a89fd1e8dc24a98b01a7ed7500698.css?ver=1616678114' media='print' onload="this.onload=null;this.setAttribute('data-loaded', '1');" />
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Pratham

    (@pratham2003)

    Hmm I think I’m just using this in the wrong way. edit: but please see the CSS links, the one being preloaded does not match the one being applied later.

    edit 2: I think we are missing a filter that allows us to modify the output.
    This part of the output specifically.
    <link rel='stylesheet' id='elementor-post-5-css' href='https://example.test/wp-content/cache/autoptimize/css/autoptimize_single_310a89fd1e8dc24a98b01a7ed7500698.css?ver=1616678114' media='print' onload="this.onload=null;this.setAttribute('data-loaded', '1');" />

    • This reply was modified 5 years ago by Pratham.
    • This reply was modified 5 years ago by Pratham.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Hey Pratham, afraid I did not get a notification about your question. Re. “missing a filter” maybe give autoptimize_filter_css_bodyreplacementpayload a shot?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    were you able to make things work with autoptimize_filter_css_bodyreplacementpayload Pratham?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    No feedback so I assume you got it working pratham2003 ? Feel free to follow up if you have questions!

    have a nice day!
    frank

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘autoptimize_fitler_css_preload_and_print bug?’ is closed to new replies.