vippsas/vipps-woocommerce

React, react dom and lodash loaded by vipps plugin

kimmenbert opened this issue · 3 comments

This plugins enqueues lodash, react etc. on every page because of this:

wp_enqueue_script( 'create-block-vipps-products-block-extension', plugins_url( 'Blocks/Products/js/index.js', __FILE__ ), array( 'wc-blocks-registry','wp-i18n','wp-element','vipps-gw' ), '1.0.0', true );

Please add checks that the all products blocks is in use on current page before enqueuing this

Right; I'll add has_block in that spot.

Though that's going to be a problem in the future when block-based widgets becomes the norm. Still, for now I'll make a test.

Fixed (for november 2020) in 1.6.2. A filter is in place to allow people using the All Products Block on other-than-pages to ensure the files are loaded.

Future plan is to use wp_script_is to check if the dependencies are all in fact queued (in which case, enqueue) and/or a backend setting to force loading of the react stuff.