You’re passing true
as the $in_footer
argument to wp_register_script()
, but my_custom_js()
is loading in the header. So doubleScroll is loading after the custom js.
I would put my_custom_js()
in a separate javascript file so you can control the dependencies.
Create my_custom_js.js in the same place you have the double scroll script:
jQuery(document).ready(function($) {
$("#double-scroll").doubleScroll();
}
Then in your functions.php use:
function dsb_adding_scripts() {
wp_enqueue_script(
'doubleScroll',
get_template_directory_uri().'/js/jquery.doubleScroll.js',
array('jquery')
);
wp_enqueue_script(
'my_custom_js',
get_template_directory_uri().'/js/my_custom_js.js',
array('jquery', 'doubleScroll')
);
}
add_action('wp_enqueue_scripts', 'dsb_adding_scripts');
Related Posts:
- Invariant Violation: Objects are not valid as a React child
- How to get all place details from a Place Details Request using Google Places API Web Service?
- How do I check whether a checkbox is checked in jQuery?
- SyntaxError: Unexpected token o in JSON at position 1
- What does the function then() mean in JavaScript?
- Heroku: “No default language could be detected for this app” error thrown for node app
- Loop inside React JSX
- Can’t resolve module (not found) in React.js
- Is there a difference between /\s/g and /\s+/g?
- How to read an external local JSON file in JavaScript?
- How do I loop through or enumerate a JavaScript object?
- Getting Unexpected Token Export
- Setting a backgroundImage With React Inline Styles
- Filter array to have unique values
- How do I chop/slice/trim off last character in string using Javascript?
- What is causing this error – “Fatal error: Unable to find local grunt”
- Escape quotes in JavaScript
- “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- Mouseover & Mouseout w/ Javascript
- Format JavaScript date as yyyy-mm-dd
- Programmatically change the src of an img tag
- Unable to preventDefault inside passive event listener
- JavaScript variable assignments from tuples
- jQuery $.cookie is not a function
- Setting background-image using jQuery CSS property
- Scroll Automatically to the Bottom of the Page
- npm WARN … requires a peer of … but none is installed. You must install peer dependencies yourself
- How do I check if string contains substring?
- What does “export default” do in JSX?
- Cannot find module ‘internal/fs’ after upgrading to node 7
- How can I select an element by name with jQuery?
- How can I group data with an Angular filter?
- jQuery disable/enable submit button
- Initializing an Array with a Single Value
- Is it possible to stop JavaScript execution?
- Remove commas from the string using JavaScript
- How can you remove all documents from a collection with Mongoose?
- TypeError: ‘undefined’ is not an object
- Uncaught TypeError: Cannot read property ‘appendChild’ of null
- javascript setTimeout() not working
- JQuery issue “TypeError: $.getJSON is not a function”
- Retrieve the position (X,Y) of an HTML element
- command not found: jest
- How to access Session variables and set them in javascript?
- Google Maps JS API v3 – Simple Multiple Marker Example
- HTML onchange (this.value)
- Javascript: Unicode string to hex
- Preloading images with jQuery
- socket.io – ReferenceError: io is not defined
- What is the difference D3 datum vs. data?
- How to check if a number is between two values?
- How to determine if Javascript array contains an object with an attribute that equals a given value?
- Line continuation characters in JavaScript
- Simulate a click on ‘a’ element using javascript/jquery
- How can I remove a style added with .css() function?
- Error: Couldn’t find preset “es2015” relative to directory “/Users/username”
- Using Angular 2 without TypeScript Transpiler
- Trigger Javascript on Gutenberg (Block Editor) Save
- How to intercept already localized scripts
- Customizer JS API
- Show control conditionally in Gutenberg
- Loading different JS for http and https
- Want image captions to be from img ALT tags not title tags
- How to get the ToggleControl Gutenberg component working for a PHP Block
- How to append a URL parameter to all outbound URLs
- wp_customize_support_script – do I need it?
- How to add a “data-” attribute to the image tag of native gallery output
- Post to WordPress using REST API from external site
- Javascript Helpers
- Rest API invalid nonce with Backbone Client
- Gutenberg block “This block appears to have been modified externally” on save
- 404 Error Contact Form 7 on WordPress
- Enqueue script if screen is greater than 500
- window.send_to_editor throws unterminated string literal error when adding image with multi line description
- Gutenberg get core data – search
- Add custom classes for blocks in editor based on custom attributes
- How to use Readmore.js? [closed]
- Trying to turn the Edit function into a class to be able to use React lifecycle methods
- Gutenberg richtext block vaildation failed
- Return ‘X-WP-Total’ from headers in response
- Javascript asset not enqueuing with the rest
- WP adds long version query strings to CSS and JS files
- jQuery UI Tools: Scrollable: More than 1 instance possible?
- imporing HTML+javascript from REST API
- Uncaught TypeError: switchEditors.switchto is not a function
- how to add a custom javascript file to our theme
- Check if user can in javascript
- WordPress Guternberg Content For React Native
- Rest API and how to deal with it in server side
- Custom block update rendering when reused
- VisualComposer/WPBakery Page Editor: Is any JS event triggered after the Edition pop-in is shown?
- How do I integrate a codepen?
- How do I add my own scripts to the add_action(‘wp_enqueue_scripts’) function?
- Post title and url not showing on google map marker [closed]
- Including js script at end of header
- contact form 7 javascript and wpcf7_before_send_mail action
- Trigger a function during onload
- Embed Kajabi into WP
- Google AdSense Ad not showing up in WordPress Blog [closed]