/**
* @module shouldLoadChunk
* @description Util to see if we should load a given chunk on a page. Just add data-load-chunk-UNIQUE to load that particular
* one on any element on the page.
*
* @since 1.0.0
*
* @param {string} name The chunk name.
*
* @return {boolean} Whether or not we should load the chunk.
*
* @example
* import { shouldLoadChunk } from "@gravityforms/utils";
*
* // assuming there is a dom node present that has the data attribute: data-load-chunk-example
* function Example() {
* if ( shouldLoadChunk( 'example' ) ) {
* import( '../example-module' \/* webpackChunkName:"scripts-admin.example" *\/ ).then(
* ( module ) => {
* module.default();
* }
* );
* }
* }
*
*/
export default function shouldLoadChunk( name = '' ) {
const node = document.querySelectorAll( `[data-load-chunk-${ name }]` );
return node.length > 0;
}