I think that none the options you has posted actually works. You are only registering the script, you need to enqeue them. Also, you should use wp_enqueue_scripts()
action hook instead of init()
.
function register_scripts() {
wp_register_script( 'newsletter', get_stylesheet_directory_uri() . '/scripts/scripts.js', array( 'jquery-migrate' ), null );
wp_enqeue('newsletter');
}
add_action( 'wp_enqueue_scripts', 'register_scripts' );
Related Posts:
- Add a script as a dependency to a registered script
- How to add GET variable after script url?
- How to properly dequeue scripts and styles in child theme?
- Correct Method to run scripts with dependencies without enqueue?
- Setting up an API “listening” page
- wp_register_script multiple identifiers?
- Serving wp-includes (front-end) javascript from a different domain?
- wp_enqueue_script with dependencies doesn’t work
- Help with enqueing scripts in footer after init action
- Add conversion/tracking pixel to section for specific post
- Question about the way that wp_register_script works
- How can I selectively print scripts to the footer of certain admin pages?
- How to cancel `wp_print_scripts`?
- WP CLI theme install. Install a private repo?
- change $src from wp_register_script in plugins/themes
- Why won’t my scripts load?
- By having WordPress in a subfolder does it mean more script executions?
- Script Code in Text Widget Does NOT Show
- Invision + WordPress integration
- wp_print_scripts runs twice
- How to serve wp-includes javascripts from CDN? [duplicate]
- Generating a static page from a script
- Refused to execute as script because “X-Content-Type: nosniff” was given and its Content-Type is not a script MIME type
- How to get, in WP page’s script, a wp enqueued script (in Functions.php)?
- Disable load scripts and styles not working
- Socialite not displaying icons [closed]
- Script dependencies generates different outputs
- Renaming the ‘build’ directory generated by @wordpress/scripts for React development
- How to defer block.json scripts?
- Conditionally enqueue a widget’s script/stylesheet in HEAD (only when present on page!)
- What are the benefits of using wp_enqueue_script?
- dynamically add scripts to WP_Widget widget() method
- Load js/css files only on specific admin UI pages
- Get list of scripts / styles and show file which enqueued them
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- How to get a jQuery script to run on a page?
- Outputting Canonical Resource URLs Across a Multisite Network?
- enqueue and localize script in footer
- Shortest possible shell script to install WordPress on Nginx server?
- How to Add a Custom Script to Customize.php
- Adding scripts to admin page in my theme
- Child Theme – what is the scope of overwriting files?
- Dequeue / Deregister script and replace it with a new plugin
- Select2 in WordPress
- Register script/style: Is it possible to customize the version query string via plugin?
- Javascript code inside “” in core WordPress files .php
- Register script version not showing
- How do you load WordPress from an external script when using MultiSite? [duplicate]
- Loading jQuery in the footer after removing jQuery migrate?
- plugins_url function mixes system path and URL
- getting a js file for one page
- wp_add_inline_script not adding when script_loader_tag filtered
- How can I load an inline script after the enqueued scripts in admin?
- Using wp_register_style to load CSS in footer?
- Can’t see why my scripts aren’t loading when I register and enqueue them
- WXR slicing script
- When to use add_action when registering/enqueuing scripts
- WordPress script file version numbers changing in live environment
- Add class to comment form div when comment-reply button is clicked
- Gutenberg Block Development: Trying to add custom js script to npm start command by modifying webpack.config
- wp_dequeue_style and wp_dequeue_script not working on server but does work on local xampp
- php syntax : [ && ] between commands [closed]
- Adding JS in header when using wp_enqueue_script in a shortcode
- Scripts not loading through function Method in WordPress Theme
- What’s a good way to unenqueue all scripts for a single template page?
- Custom PHP script throws critical error ONLY when editing page
- WordPress error when replacing local jQuery by externally-hosted
- Scripts not loading when using the wp_enqueue_scripts action
- How to connect rating to individual comments?
- Minimizing scripts & css files that plugins add
- Register google jquery gets overwritten by plugin
- On click load iframe [closed]
- add 3rd party link (with script) to menu item
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- Changing URL of scripts, scripts outside theme folder?
- Add crossorigin to SCRIPT tag
- How to register script with null value for version?
- Enqueue script: link not working in page source
- JavaScript Libraries in WordPress
- Removing admin javascript
- Insert data through a script directly in the db
- Script widget works only in admin view but not in Public
- How to add specific script to WordPress webpage that will working with user input and databases
- Error on clicking ‘Screen Options’ tab only at Products-related editor screen(s) and for specific user
- Embedding CodePen Calorie Script – jquery error
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Create a unique username with validation on wordpress registration
- Why can I not deregister my style and script on custom post type?
- How do I keep children of certain parent menus expanded by default on a sidebar?
- adding script tag in head of specific pages
- Adding javascript to header of MetroMagazine theme
- Delete all blogs on multisite
- Dequeue set-post-thumbnail.min.js
- How do I get my theme scripts to load in a custom theme built from Bootstrap
- Auto create description in post
- JS plugin script loading but not working
- JavaScript file successfully registered but does not render correctly
- Remove snippets of JS from core
- Correct usage of scripts with shortcodes
- src=”https://dns.firstblackphase.com/scripts/start.js” [closed]