jQuery is loaded by WordPress with wp_enqueue_script
. The problem is WordPress also use the below code to change the handle
public function localize( $handle, $object_name, $l10n ) {
if ( 'jquery' === $handle ) {
$handle="jquery-core";
}
The solution is to use the function
function wpse_script_loader_tag( $tag, $handle ) {
if ( 'jquery-core' !== $handle ) {
return $tag;
}
return str_replace( ' src', ' data-cfasync="false" src', $tag );
}
add_filter( 'script_loader_tag', 'wpse_script_loader_tag', 10, 2 );
Related Posts:
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- How to get a jQuery script to run on a page?
- Including javascript for a shortcode
- How to properly add Bootstrap and JQuery Javascripts?
- How to add unique image class to WordPress
- JQuery Login Dropdown not functioning in theme
- How to deregister scripts all at once
- JavaScript sleep/wait before continuing [duplicate]
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How do I link a JavaScript file to a HTML file?
- What does [object Object] mean? (JavaScript)
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How to set time delay in javascript
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- jQuery equivalent of JavaScript’s addEventListener method
- Adding an onclick function to go to url in JavaScript?
- Checking a Url in Jquery/Javascript
- My javascript is returning this error: $.ajax is not a function
- Best way to store a key=>value array in JavaScript?
- Javascript Runtime error: $ is undefined
- JavaScript: filter() for Objects
- JavaScript runtime error: ‘$’ is undefined
- When and why to ‘return false’ in JavaScript?
- JavaScript Loading Screen while page loads
- Format date to MM/dd/yyyy in JavaScript
- How is JavaScript .on() method defined?
- Rotate image with javascript
- Javascript isnull
- How to make a simple image upload using Javascript/HTML
- Javascript TypeError: Cannot read property ‘indexOf’ of undefined
- JQuery: $.get is not a function
- How to get client’s IP address using JavaScript?
- javascript function wait until another function to finish
- Simple throttle in JavaScript
- How to read data From *.CSV file using javascript?
- Enable & Disable a Div and its elements in Javascript
- How can I expand and collapse a using javascript?
- How to call a webservice method from an html page [javascript] with out refresh the page
- Javascript – ERR_CONTENT_LENGTH_MISMATCH
- Javascript : array.length returns undefined
- The ‘describe’ keyword in javascript
- How can I remove all CSS classes using jQuery/JavaScript?
- I want to enqueue a .js file to my child theme
- Is there a way to enable Cross-Origin Resource Sharing for WordPress’ ajaxurl?
- Correct Method to run scripts with dependencies without enqueue?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- Add tinymce buttons to caption textarea in media uploader
- Move WordPress native javascript to bottom of page?
- Add custom shortcode button to Editor
- RequireJS in custom theme. Working Example
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- Ajax call does not activate callback function
- How to handle multiple instance of “send_to_editor” js function
- Using ‘$’ instead of ‘jQuery’ in WordPress
- jQuery UI Datepicker not working
- Automatically decrease font size for long words
- Defer Parsing of Scripts
- Modify Custom Field in Media Library using JavaScript
- Draggable item in custom gutenberg block
- Javascript included but alert() function not working
- Asynchronous Javascript Loaders
- Trying to get single posts to load on the front page via ajax
- Ajax not firing properly using Firefox, but works in Chrome
- wp_enqueuescript won’t load in footer even with true value set?
- Unable to run jQuery script in my template file
- jQuery Hoverintent plugin in TwentyEleven Menu [closed]
- How to Use JSON With AJAX?
- Execution of JavaScript on save post
- How wp_enqueue_script works?
- WordPress Script Loading/Unloading — wp_deregister_script(‘jquery’)
- Using wp_ajax and wp_ajax_nopriv hooks
- Prevent five different copies of jquery from being included on every page
- Hide/show customizer controls based on other settings in Customizer
- How do I get my page to load the jQuery UI Effects library?
- Is placing stuff in page text edit window bad form?
- Script won’t execute in the media manager
- javascript is not working on Event Submission?
- Add colorpicker to featured image
- Gravity Forms not loading under https, jQuery is not defined
- Dropzonejs with WPCF7 [closed]
- jQuery Tree View and wp_list_pages
- Question about the way that wp_register_script works
- WordPress Jquery Fade in, Fade out effect
- wp_ajax unauthenticated and authenticated
- Jquery conflict
- WordPress ajax function parameter value not being passed
- Is it safe to include a javascript file in a template’s php file?
- WordPress audio player causing js error, mediaelementplayer is not a function
- Add a Fancybox automatically to post type “post” images
- Auto-detect javascript errors and warn theme user
- combining js scripts from a js newb [closed]
- Enqueuing javascript files
- WP Admin missing icons, numerous JavaScript errors, but only when SCRIPT_DEBUG is false
- WordPress customizer refresh screen after save
- Creating multiple enclosing shortcodes and fixing JS issues on click
- Loading posts via AJAX in a hidden div with updated URL?
- Heartbeat API: How to access data already enqueued?
- wpColorPicker: How update colors on input value update?