#bug #console #dev tools #development #error #google chrome #javascript #setup
Provides an instant overview of your shop's current customers and the contents of their carts.
WordPress 3.6 (august 2013) comes shipped with jQuery version 1.10.2. All good.
jQuery 1.10.2 however has this new thing where it has a path to the source map specified on the 2nd line which tells supporting browsers to look for the source map file in that location (specifically “/wp-includes/js/jquery/jquery-1.10.2.min.map”). Supplying the jquery source map file is optional, but having that path specified does make the browser look for it and spit out a nasty 404 when it doesn’t find it.
Somehow this version of WordPress got released with the source map file missing and thus a clean install will generate a console error in the latest Chrome, Firefox, Opera… like OMG, right? Let’s explore some ways to fix it.
Simply opening /wp-includes/js/jquery/jquery.js and removing the path to the source map will make it stop looking for it. This however means you are editing the core WordPress files and it will get overwritten at the next update. Since the next update hopefully has a fix for this issue, that shouldn’t be much of a problem.
// Remove following line in /wp-includes/js/jquery/jquery.js:
//@ sourceMappingURL=jquery-1.10.2.min.map
Get the “map file” from jquery.com and add it to your WordPress install’s /wp-includes/js/jquery/ to make jquery happy. Again, this is out of the theme / plugin scope so you are altering the WP core, but not doing any damage. This is also the only way to actually start using the sourcemap functionality.
A method that would not alter the WP core structure is to deregister jquery from your theme or plugin, and optionally registering a new and or modified one. Just keep in mind that this can easily mess with other dependencies, code quality requirements when selling your work and future compatibility depending on your project and plans to keep the code current.
// Deregister the default jquery in your functions.php:
function my_enqueue_scripts(){
// De-register:
wp_deregister_script('jquery');
// Re-register:
wp_enqueue_script('jquery', get_template_directory_uri().'/js/jquery.js', array(), '1.10.2');
}
add_action('wp_enqueue_scripts', 'my_enqueue_scripts');
I’m not pointing fingers but jQuery should provide a seperate non-default source map supporting version if it requires additional files to be present, browser vendors should be less strict about a missing //@ sourceMappingURL file and WordPress should have made a choice of either supporting sourcemaps or leaving the filepath out somehow.
Posted by Berend on
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Привет!