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
- 404 error on page reload
- Validate a custom form with js and php
- Custom filter not affecting gtag script position in WordPress footer
- Question about the template-loader.php file
- Is $hook a global variable in WordPress
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Replace existing content from specific WooCommerce admin orders list column
- Using a javascript file to access a get posts array
- My shortcode is showing up twice
- Using an Image Slider twice on the same page
- Database “Migration” for Plugins?
- WordPress template_include filter not working properly
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- How does WP detect format type (and can I make use of this)?
- When is is_admin() available?
- Create table in database when activating plugin
- do not show web page section when using advanced custom fields pro
- How to get all existing post types
- Executing `createimagefrompng()` from save_post hook (or equivalent hook)
- JavaScript, best way to use data from the loop
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Using wp_get_image_editor in a standalone script
- Javascript code inside “” in core WordPress files .php
- New Plugin Review
- Problem with WordPress Ajax form
- Minify HTML, CSS, JS with PHPWee?
- Theme url in all plugin pages
- Run a Parallel PHP Application with WordPress
- Getting my head round WordPress filter
- Click loads template via ajax
- allow user to select pages from dropdown in my plugin
- Delete option value from array using update_option()
- Am I not understanding plugins?
- Archive dropdown styling not applied
- enqueue hover function
- Continue execution after WP REST API response
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- WordPress Ajax Custom Query – High CPU LOAD
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- “The plugin generated 2694 characters of unexpected output…” on Plugin activation, CREATE TABLE sql command not working
- Using Font Awesome as post thumbnail
- How to display a value from a radio button in the options menu in wordpress
- How To Change The Html of Products filtration sidebar in Woocommerce?
- Display notification only once
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Access/update database with jQuery
- allow users to publish without admin approval
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- How to start a script from cli within wordpress
- Get/Set wp.customize.previewer.previewUrl
- javaScript in section of WP API
- Insert all post IDs in new database table