Thursday, December 8, 2022
HomeWordPress Developmentcapabilities - dynamically import array from one other js file in Wordpress

capabilities – dynamically import array from one other js file in WordPress


Tips on how to dynamically import array from one other js file in WordPress? One file (advertisements.js) is a script and one other (ads-REKLAMY.js) has simply arrays to export.

My each recordsdata are enqueued like this in my capabilities.php file:

wp_enqueue_script('advertisements', get_template_directory_uri() . '/js/advertisements.js', array( 'ads-REKLAMY' ), $timestamp = filemtime( plugin_dir_path( __FILE__ ) . '/js/advertisements.js' ), true);
wp_enqueue_script('ads-REKLAMY', get_template_directory_uri() . '/js/ads-REKLAMY.js', array(), '1.1', true);

For now it appears like this, however I would want to alter it everytime i make modifications within the ads-REKLAMY.js file.

import { advertisements, adsP } from "./ads-REKLAMY.js?ver=1.1";

And naturally I cant simply import it like regular file, as a result of then it wouldnt replace after making modifications in file with arrays.

Can I one way or the other hyperlink them so I can dynamically import arrays from one js file to a different? Perhaps one thing with enquing script with dependency as a parameter.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments