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');
If anyone has this issue. Good news! I found the fix. We are supposed to add scripts like this
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/