Closed ipatate closed 2 years ago
The assets is in all pages. For the moment i use this snippet for remove assets if the block isn't in page.
/** * Completely remove assets from plugin block leaflet if isn't in page */ function disableLeafletAsset() { $id = get_the_ID(); if (!has_block('map-block-leaflet/map-block-leaflet', $id)) { wp_dequeue_script('lib-js-map-block-leaflet'); wp_dequeue_script('lib-js-map-block-leaflet-cluster'); wp_dequeue_script('js-editor-map-block-leaflet'); wp_dequeue_style('css-editor-map-block-leaflet'); wp_dequeue_style('lib-css-map-block-leaflet'); wp_dequeue_style('lib-css-map-block-leaflet-cluster'); } } add_action('wp_enqueue_scripts', 'disableLeafletAsset');
Thanks for your contribution, in the past I had problems trying to exclude those assets. I will try your solution.
Added in version 2.1.0
The assets is in all pages. For the moment i use this snippet for remove assets if the block isn't in page.