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
- Display message once per session to users with a specific role
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- wordpress custom endpoint multiple params
- Run a Parallel PHP Application with WordPress
- How do I display a user’s previous orders as a select box option on a product?
- ajax, right way to do it and make it works?
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Sending data from custom inputs in WordPress comment form in the admin notification email
- How to insert data into database using wp cron job
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- Access Child Class of Plugin Main Class Instance
- Modify custom field input data before creating a new post
- Font Awesome changing default WordPress Font
- Download full html page with CSV export plugin
- How do I add $_SESSION[”] to my wordpress page?
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Run JS Code on userlog out
- Removed jQuery script from header.php , any problems?
- Hot to check if new posts have been published since page load and notify online users?
- How does add_option() function enable action hooks to fire right after actiavtion?
- save_post trigerred twice
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Unable to display multiple parameters from url by javascript through shortcodes
- Wp_Schedule_Event every few minutes doesn’t work
- Ajax search box displays nothing if taxonomy doesn’t exist
- How to import woocommerce custom fields data into another site?
- Store data from JavaScript object to custom table in user account
- Add a custom link to each image in WordPress gallery
- Javascript Tab Gallery with Advanced Custom Fields
- Generate a radius search of custom post type locations
- custom field – changing an element or background of id div – different versions not working
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- PHP get_category() function redeclared
- wp_query (or hook) posts by date (id) in array then set post_type
- Chosen Select jquery Not Working in Plugin
- PHP calling function within a class
- Save data of select list after clicking save
- How to hide Ads From Certain Categories?
- Custom field fetch error on woocommerce pdf invoice
- Displaying custom meta box value in a custom post page
- how to check elementor is widget is active or loaded
- Create a custom plugin with dynamic child pages listing database records
- how to assign javascript variable value to php variable in wordpress