Support » Plugin: Autoptimize » PHP check for lazy load?

  • Resolved Carl Gross


    Is there a reliable PHP hook or function I can use to check if the Autoptimize lazy load feature is activated?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Optimizing Matters


    sure: autoptimizeImages::should_lazyload_wrapper() should work.

    OK thanks for that. But can you give an example of how I would use it in my code? In my case, my code is in a plugin (a must use plugin). I tried adding this line to my code:

    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    if ( ! is_plugin_active( 'autoptimize/autoptimize.php' ) ) {
    error_log( print_r( autoptimizeImages::should_lazyload_wrapper(), true ) );

    But it returned:

    [19-Jan-2020 07:29:47 UTC] PHP Fatal error: Uncaught Error: Class 'autoptimizeImages' not found in /home/horizon/domains/


    Plugin Author Optimizing Matters


    the code probably just runs too early, try to hooking everything into an action, plugins_loaded or something?

    Ok thanks. I attached it to the wp hook for now, and it worked. I’ll try switching to the plugins_loaded hook later.

    We can consider this resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.