Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1241311

    We noticed that all shortcodes assets (like css and js files) are loaded disregarding which shortcodes are present on the page.
    We would like to load only ones that are present on the page. Is that possible?

    If not, is that possible to combine them in 1 file?

    Also we’d like to understand if it’s possible to disable loading of certain assets programmatically (e.g. via php / WP filter) so we’ll disable them manually if there is no automatic solution.

    #1241875

    Hey aph80,

    It’s not possible to load only the CSS which is present on one page unfortunately, but you can compress the CSS and JS files into one under Enfold->Performance. You can also manage which elements you want to include on the same page, you can exclude elements which you don’t use on the site for example.

    Best regards,
    Rikard

    #1242100

    You can also manage which elements you want to include on the same page, you can exclude elements which you don’t use on the site for example.

    I don’t understand this. You’re saying we can only remove components globally?

    Anyway, we want to understand how styles and scripts are registered for shortcodes in php so we can dequeue them manually in php depending on the page. Can you provide more info on this?

    #1243139

    Hi,

    Have you tried setting the Performance > Disabling of template builder elements settings to the second option (Load only use elements)? As the option title says, it will only load elements that actually exist in the page.

    Each shortcode registers its own script and stylesheets in their designated templates using the extra_asset function.

    Example in the config-templatebuilder\avia-shortcodes\buttonrow\buttonrow.php file.

    public function extra_assets()
            {
                //load css
    			wp_enqueue_style( 'avia-module-button', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/buttons/buttons.css', array( 'avia-layout' ), false );
                wp_enqueue_style( 'avia-module-buttonrow', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/buttonrow/buttonrow.css', array( 'avia-layout' ), false );
            }
    

    Best regards,
    Ismael

    #1243452

    Thanks, so I just can wp_dequeue_style('avia-module-buttonrow') or do I need somehow to override function in the class?

    #1244181

    Hi,

    Yes, using the dequeue or deregister function should disable the scripts and stylesheets if necessary. Have you tried adjusting the Performance > Disabling of template builder elements settings as suggested above?

    Best regards,
    Ismael

    #1244931

    @Ismaeil,
    yes we tried that but it doesn’t work for us for some reason.

    #1245592

    Hi,

    Did you enable the File Compression settings, or install cache and minification plugins? You might have to disable the cache and compression options first. If it still doesn’t work after disabling the options or plugins, then you can proceed by using the dequeue or deregister functions to manually disable the scripts or stylesheets when they are not needed.

    Thank you for your patience.

    Best regards,
    Ismael

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