Your second wp_enqueue_script() contains the same handle (the same ID) as the first wp_enqueue_script().
The handle is the ID by which a registered script is known to WordPress internally. If you use this ID a second time, the second script won’t be registered.
A working example could be this one:
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles_and_scripts' );
function theme_enqueue_styles_and_scripts() {
wp_enqueue_style( 'fonts', get_stylesheet_directory_uri() . '/assets/fonts/icons/style.css');
wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/assets/js/main.js');
wp_enqueue_script( 'compiled-script', get_stylesheet_directory_uri() . '/assets/compiled.js');
}
Related Posts:
- What are the benefits of using wp_enqueue_script?
- wp_register_script multiple identifiers?
- How do I enqueue(or delay loading of) tags in individual page posts?
- wp_enqueue_script adds only the first script
- Why is JavaScript being added to header as application/oembed?
- JavaScript Libraries in WordPress
- Setting Variable Path to Template Directory inside Script
- How to load Javascript code or functions.php later in a child theme?
- Enqueued script fails
- wp_enqueue_scripts doesn’t work for template pages
- Dequeue set-post-thumbnail.min.js
- What does wp-embed.min.js do in WordPress 4.4?
- How to use wordpress default Password Strength Meter script
- How to properly dequeue scripts and styles in child theme?
- Adding javascript to child theme
- Register and enqueue conditional (browser-specific) javascript files?
- wp_enqueue_script() not working at all
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- wp_enqueue_script : how to change loading order of scripts?
- Remove extra Google Maps script
- What does wp-list.js do?
- Include jQuery UI as a whole
- How to echo JS right after enqueued script to put it into noConflict mode?
- Editing Source Code in WordPress
- wp_localize_script with boolean and init
- require.js to load javascript
- wp_enqueue_script isn’t connecting my custom js file
- Including javascript for a shortcode
- TinyMCE in a div / textarea on frontend?
- Include Javascript as Plain (No file inclusion)
- Move all the JS files to the bottom|footer, the right way
- Disable unneeded scripts in a wordpress installation
- Javascript not working?
- How to properly add Bootstrap and JQuery Javascripts?
- How do I change number of columns in a proper way in twentyfourteen child theme?
- Is it mandatory to enqueue any kind of Javsacript?
- wp_enqueue_script & constants?
- Can the index.asset.php file be used with the enqueue_block_editor_assets action?
- Adding tawk.to code just before body tag on functions.php file
- wp_enqueue_scripts is not working in my plugin
- Exclude JS file from 404 error page
- Building a slide down search box in wordpress
- Enqueue script if screen is greater than 500
- Script Localization doesn’t work
- Is there a way to check for an attribute of a script when using script_loader_tag?
- Enqueue scripts all over but not in single.php
- Override do_item() Function to Add Extra Attribute to Scripts
- Proper way to enqueue a generated script that isn’t in a .js file?
- a child theme not de-registering a patent javascript file
- wp_enqueue_script not loading my custom js file
- Correctly enqueue scripts of type=text/paperscript (PaperJs Library)
- Scripts not loading through function Method in WordPress Theme
- wp_enqueue_scripts not enqueing correctly
- Video script issue, JavaScript attribute remains ‘undefined’
- On click load iframe [closed]
- Do I just put the html in a page when enqueueng or do I also have to reference js file from the html page [closed]
- Add crossorigin to SCRIPT tag
- How do I know if I should enqueue JS code or just include it in ONE PHP function?
- Including Styles and JS files to work ON my plugin interface
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- wp_enqueue_script does not recognize my js file?
- What to include to use jQuery UI Auto Complete
- Bootstrap bundle present in page source but not working
- Dynamically add Js
- JS / jQuery in Elementor pages vs JS file
- Script widget works only in admin view but not in Public
- Script Loaded in WordPress but won’t run
- Error on clicking ‘Screen Options’ tab only at Products-related editor screen(s) and for specific user
- Is it possible to override only a part of another plugin’s / theme’s js (asset) file?
- How to pass data to javascript in custom widget class
- Loading two versions of same JS libary
- Proper way of minifiying java script files in wordpress theme
- Including js script at end of header
- JavaScript code do not works on online server
- How to register or enqueue script and stop it being called in head?
- Adding javascript script to header via functions.php
- adding script tag in head of specific pages
- How to delay display of page elements until enqueued script has injected html
- load-scripts.php loads incorrect file names
- Enqueue concatinated JS file in WordPress
- JavaScript and Google PageSpeed + wp_enqueue_script
- Javascript file doesn’t load
- Put dynamic Javascript in header after doing operations
- early enqueueing javascript file in page template, not in functions.php
- jQuery + more won’t load in header
- JS enqueue path (localhost)
- Why can’t I load JS script in a plugin?
- Script loaders vs wp_enqueue_script
- convertEntities() used before it is defined
- JavaScript file successfully registered but does not render correctly
- wp_enqueue has a resource but doesn’t generate a script tag [duplicate]
- Orbit Slider and Events Manager Plug-in JavaScript
- Change color of a specific word generated by script [closed]
- How to load JavaScript modules with script_loader_tag hook?
- Scripts don’t enqueue after removing plugin
- How to securely set dynamic HTML content with JavaScript?
- CCF7 Field numbuer prefilled after Click event
- How can I access custom data fetched from posts in a javascript script?
- Why is my JS not working on initial load?
- enqueue_custom_scripts isn’t working