Unable to enqueue js files in wordpress

352 Views Asked by At

I have been trying to convert my bootstrap theme to a WordPress theme but as soon as I add my js file I get this memory error.

The error looks like this

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in C:\xampp\htdocs\livedinner\wp-includes\class.wp-dependencies.php on line 312

This was my code


function theme_js()
{

     wp_enqueue_scripts('popper_js',get_template_directory_uri() . 'js/popper.min.js' , array('jquery'),
            '1',
            true );    


}



add_action('wp_enqueue_scripts','theme_js');
1

There are 1 best solutions below

0
On

If anyone has this issue. Good news! I found the fix. We are supposed to add scripts like this


function blogsite_regitser_scripts()
{

    wp_enqueue_script('blogsite-jquery','https://code.jquery.com/jquery-3.4.1.slim.min.js',array(),'3.4.1',true);

}

add_action('wp_enqueue_scripts','blogsite_regitser_scripts');

Earlier I was using wp_enqueue_scripts and wp_enqueue_scripts is a completely different function. You can read more here https://developer.wordpress.org/reference/functions/wp_enqueue_script/