It is correct to enqueue external scripts with that function?
It works but doesn’t it slow down opening the site?
wp_register_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=true', null, null, true );
wp_register_script( 'jsapi', 'https://www.google.com/jsapi', null, null, true );
wp_register_script( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', null, null, true );
wp_register_script( 'unveil', get_template_directory_uri() . '/new-js/jquery.unveil.min.js', null, null, true );
No, it doesn’t slow the site (at least not enough to make it a reason for not using it). This is the correct way to enqueue any type of script in WordPress. All this function does is add the proper
<link>
tags (with dependencies) to your HTML<head>
.However, for some reason, you haven’t included dependencies in your code. For example, Bootstrap requires jQuery, so you should include it in your function:
As shown above, you should also consider using
wp_enqueue_script()
instead ofwp_register_script()
, since it will save you a step.