• Hello,
    I am using two scripts on my site they are enqueue in the functions file of my child theme using the:

    <?php
    add_action('init', 'loadJs');
    
    function loadJs() {
    	if (!is_admin()) {
    
    		wp_register_script('jquery.imgpreload.min',
    		get_stylesheet_directory_uri() . '/js/farinspace/jquery.imgpreload.min.js');
       		wp_enqueue_script('jquery.imgpreload.min');	
    
    		wp_register_script('marquee',
    		get_stylesheet_directory_uri() . '/js/marquee.js',
    		array('jquery') );
       		wp_enqueue_script('marquee');
    	}
    }
    ?>

    the only way I can get these to run is if I do a find and replace in both js files and use find $ and replace with jQuery, so now is that correct, or am I setting myself for conflicts?
    Thanx a million,
    henryLemmon

Viewing 1 replies (of 1 total)
  • Thread Starter henrylemmon

    (@henrylemmon)

    correct me if i am wrong:
    I changed:

    $(document).ready(function()
    to
    jQuery(document).ready(function($)

    and I added the var below as a global to handle all the instances of the $ that was not insice of the document.ready function.

    var $ = jQuery;

    Is that what I am supposed to do? I know it works this way, it also works if I change all the $ to jQuery, but I did not think that was right, so let me know.
    Thank you!
    henrylemmon

Viewing 1 replies (of 1 total)
  • The topic ‘adding javascript and using javascript’ is closed to new replies.