Turns out to be quite simple in WordPress 6.5.
Use wp_register_script_module to register the imports, and include them as dependencies in wp_enqueue_script_module:
add_action('wp_enqueue_scripts', 'enqueue_three_d_script');
function enqueue_three_d_script() {
wp_register_script_module(
'three',
"https://unpkg.com/[email protected]/build/three.module.js",
array(),
null
);
wp_register_script_module(
'three/addons/',
"https://unpkg.com/[email protected]/examples/jsm/",
array(),
null
);
wp_enqueue_script_module(
'three-d-script',
SCRIPTS_DIR . 'threeDTest.js',
array('three', 'three/addons/'),
null
);
}
Related Posts:
- Using register_activation_hook in classes
- Custom plugin: Trying to show saved data on frontend
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Change Password Hint
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Create custom blocks for bootstrap
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- Page Reloads Before AJAX Request Finishes
- action hook wp_head higher priority as all other plugins/hooks
- How to call function at the bottom of post using plugin?
- How to test nonce with AJAX – Plugin development
- wp_loaded hook block script enquequing
- How to select the contents in the text view textrea in wp_editor?
- Adding widgets to my plugin page instead of WordPress dashboard
- How to send Ajax request from my plugin in admin dashboard?
- Adding function to Genesis genesis_header [closed]
- AJAX success response is not working but it’s saving my changes
- Are all hooks/functions tied to Kses meant for sanitization?
- Is it save to use eval for a jQuery callback method coming from the database?
- wordpress admin plugin menu custom css
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- WordPress – Get Posts with Category data
- How to use wp_send_json() and output the value with ajax?
- Variation prices breakdown only for single product page
- Settings API form – submit with AJAX
- How to extend SelectControl with data from my theme
- Post form – AJAX won’t upload featured image – Plugin development
- Use wp_head hook on template page
- Creating a POP Alert
- How do I disable cache for a certain page?
- using filter and hook inside class
- get Woocommerce product format json for WP_Query
- Register/enqueue scripts only on certain admin pages
- register dependency css and js inside a plugin class
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- Why this plugin is not working?
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- Is there a way to pull remotely generated XML, process it, and display it on a Managed WordPress page?
- how to escape alert/window.location.replace with variable
- JQuery UI Autocomplete showing as bullets
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Add a class to links in the visual editor (how to get old dialog back)
- Calling a method from functions.php on a click of a button
- Get post meta in enqueued js file
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- Making Quote Plugin more efficient
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- How can I output a php value into a JS file within WordPress?
- How to add a second ‘place order’ button in WooCommerce [closed]
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- remove wp floating submenu in wp dashboard
- Reprinting tags with all attributes
- Need Help Fixing My Iframes [closed]
- wp_enqueue_scripts leads to error
- Add a product to checkout via form
- Return a numerical function value in Customizer controls
- Passing UTM Parameters To Modify Page In WordPress
- edit_comment_link is not showing for comment author
- How to hook code to show after the_content?
- Run a code only on theme activation only during first activation
- Problem with AJAX in wordpress plugin
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Can’t add script immediately after the opening tag on login page?
- Incrementing PHP variable onclick to display posts by month
- How to use custom Javascript code inside a plugin?
- JS file is not loading when i put wp_head() and wp_footer
- How to add 3 weeks to the_time() function
- Additional file upload in Gutenberg page options/featured image
- Display WordPress search results based on the selected Sub-Category
- Woocommerce disable order item link (backend) [closed]
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- WP Hook Before a post is created
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Store user form submitted information in post type
- Show subcategory name selected in specific category woocoommerce
- Upload images from one server to an other in wordpress
- Run code before WordPress loads and insert data into WP if need be
- add bootstrap modal after login in wordpress
- Add specific phrase after every product title including the discounted price? [closed]
- link to page_for_posts
- Assign new post author IF another user in custom field on post transition
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- How do I change the Go To Categories link in the term_updated_messages
- understanding wp_next_scheduled
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Load style and script for custom post type metabox
- Permissions error when I use my plugin to delete comments in the front-end
- How can i add a script with parameters?