Pretty straightforward answer is both are the correct. In first method you are breaking down the process in two steps. That is needed in case you want to register some scripts but want to load them conditionally at some later time. For example you may want to load some script only when some second script requires this first script. In this case you can simply register your first script and while enqueuing the second script you can specify the handle of your first script as a dependency.
More clear way of explaining this is think jquery. WordPress registers it by default for you. If you want to use jquery in your site you can either simply enqueue it or enqueue another script which has dependency on jQuery.
If you straight away want to use your scripts then the other method is quite short and clean.
Related Posts:
- Why is style.css not being enqueued?
- How to enqueue style before style.css
- Load custom css after bootstrap
- Relative path in wp_register_style not working
- Remove Open Sans from Twenty Twelve theme
- Enqueue Google Web Fonts Without Messing Up Symbols In URL
- Inbuilt style for jquery-ui-datepicker
- How to conditionally enqueue a stylesheet only for a certain page(s)?
- What is the correct way to enqueue multiple CSS files?
- Remove wp_add_inline_style
- Is it possible to enqueue a raw CSS string directly from within a template file?
- Avoid to load default WP styles in login screen
- How do I register/enqueue a custom CSS file?
- Use wp_enqueue_scripts, not wp_print_styles?
- Why isn’t my theme processing SASS?
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- Adding style sheet to specific page
- How Can I Use A Child Theme Effectively When Parent’s CSS Is Located in a ‘CSS folder’?
- WordPress Register Style Called Incorrectly
- Disable child theme css on certain pages
- When enqueing a stylesheet, is it possible to remove the type attribute? [duplicate]
- Enqueue style for Password Reset page
- Is it possible to change the path of a css file that is registered through wp_enqueue_style()?
- Relative path instead of absolute for wp_enqueue_script
- get_stylesheet_uri returns wrong path
- Override load-styles.php with admin screen css
- CSS file not registering through add_action
- Custom Admin CSS styles to style media uploader?
- getting url in wp_enqueue_style
- How the Css File is Linked without calling it in header.php?
- Changes in enqueued / registered stylesheet paths not updating—why?
- Loading different stylesheet on WordPress pages?
- Use wp_add_inline_style to add code to before wp_head?
- why enqueued styles in header.php shows in footer?
- How to insert html/css/javascript code to wordpress plugin
- Adding external stylesheet after ALL other styles
- Different ways to load child theme css
- How to enqueue a random css style?
- How to override Bootstrap css with my child theme css in wordpress?
- Enqueue styles in new site editor in WordPress 5.9
- How to organize priority of plugins CSS files?
- why this media query is not working / not loading when I put it in child theme?
- How do I view registered syles and scripts for enqueue
- How do I make header.php use different css for different pages?
- Load CSS in footer, like your can with JS?
- Child theme stylesheet not always overriding “index”
- my custom css file downloads then it STOPS!
- Child Theme CSS not showing at all
- Faster fonts on mobile
- Split Media Queries in different files!
- Style file inclusion
- Display Something in the Header After All Styles are Loaded
- My CSS suddenly doesn’t load anymore [closed]
- How can I force Dynamic CSS via ACF values to update on page load?
- functions.php – inject inline css from file
- Append style tag in head while shortcode runs
- How can I move my custom css to the very bottom of the head section?
- CSS getting injected into index from somewhere after theme/custom CSS is loaded, overriding all of my CSS [closed]
- enqueing Javascript and CSS
- I can’t add CSS with functions.php
- Load custom CSS before admin CSS
- Including CSS files in HEAD based on page content
- How would one set or override a Fallback font for characters in second language?
- First element/selector of enqueued CSS file breaks
- Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed
- Dequeue styles with query doesn’t work
- Save custom option in CSS file
- How to enqueue stylesheets in child-theme functions.php?
- Dequeing Parent Fontawesome Deques Parent Styles
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Add inline CSS to login page with wp_add_inline_style
- Bootstrap Integtration
- Set different css stylesheet for specific pages [duplicate]
- My Child Theme CSS Isn’t Working
- How to disable all css from the theme for a specific post type page
- Font size decreases when child theme is created from parent theme?
- Controling css order
- Modify arguments for parent theme’s `wp_register_style` via child theme
- Why are my parent styles loading after my child styles?
- How to make CSS load live based on options clicked in the theme customizer?
- Replacing parent theme’s IE-specific CSS
- Browser stacks different versions of style.css
- Bootstrap 4 Optimization
- How to create my own style.css file in an wordpress child-theme
- Enqueue MCE Editor CSS in admin page
- plugin not loading my css and js
- Custom theme – Bootstrap CSS not loading via wp_enqueue_style or otherwise
- How enqueue CSS out of theme folder?
- Set line spacing
- How to get current screen width in CSS?
- Hexagon shape with CSS3
- is it possible to use post-type as part of a css selector in block editor stylesheet?
- Bootstrap in theme
- How to align full div [closed]
- How to add inline css code with background image in page html code?
- str_replace inside specific css files [closed]
- Apply custom css for user role
- override a css style [closed]
- CSS properties in textarea in the Customizer
- Editing size of h3 tag in wordpress on a one-off basis