Support

Account

Home Forums Add-ons Flexible Content Field Check if layout is used Reply To: Check if layout is used

  • You could register your script in functions.php and then enqueue it right where you need. So, just as a mere example:
    in functions.php

    wp_register_script( 'gmaps','https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '1.0', true );
    

    and then in your layout code:

    elseif( get_row_layout() == 'map' ):
    
            $google_maps = get_sub_field('google_maps');
            if( !empty($google_maps) ):
            wp_enqueue_script('gmaps');
    

    This will load google’s .js in footer just when you need it.