Every time I try to register and enqueue script in my function.php file I get the error
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried
to allocate 261904 bytes) in C:Program Files (x86)Apache Software
FoundationApache2.2htdocsnamewebsitewp-includesclass.wp-dependencies.php
on line 178
here is the code used in my functions.php file
function load_external_js() { // load external file
wp_enqueue_script('jquery');
wp_register_script('hash-change', get_template_directory_uri() . '/js/jquery.hashchange.event.plugin.js', array('hash-change'), '', true );
wp_enqueue_script('hash-change');
wp_register_script('ajax-theme', get_template_directory_uri() . '/js/ajax-implementation.js', array('ajax-theme'), '', true );
wp_enqueue_script('ajax-theme');
}
add_action('wp_enqueue_scripts', 'load_external_js');
How can I fix this?
You are requiring scripts as dependencies of themselves:
wp_register_script('hash-change', get_template_directory_uri() . '/js/jquery.hashchange.event.plugin.js', array('hash-change'), '', true );
wp_enqueue_script('hash-change');
change your call to wp_register_script to
wp_register_script('hash-change', get_template_directory_uri() . '/js/jquery.hashchange.event.plugin.js');
Or, if you’re really meaning to require another script as a dependency, register that script and reuire it by the handle you give it.
If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 64M. If your line shows 64M try 128M
memory_limit = 64M
; Maximum amount of memory a script may consume (32MB)If you don’t have access to
PHP.ini
try adding this to an.htaccess
file:php_value memory_limit 64M
Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define('WP_MEMORY_LIMIT', '64M');
Talk to your host.
Found in: http://wordpress.org/support/topic/fatal-error-allowed-memory-size-6#post-1017842