-
AuthorPosts
-
August 27, 2020 at 10:21 pm #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.
August 30, 2020 at 4:59 am #1241875Hey 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,
RikardAugust 31, 2020 at 11:26 am #1242100You 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?
September 3, 2020 at 4:44 pm #1243139Hi,
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,
IsmaelSeptember 4, 2020 at 10:31 pm #1243452Thanks, so I just can
wp_dequeue_style('avia-module-buttonrow')
or do I need somehow to override function in the class?September 8, 2020 at 7:08 am #1244181Hi,
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,
IsmaelSeptember 10, 2020 at 2:37 pm #1244931@Ismaeil,
yes we tried that but it doesn’t work for us for some reason.September 14, 2020 at 4:11 am #1245592Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.