function add_scipts() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', '', true, '3.1.x');
wp_enqueue_script('jquery');
wp_enqueue_script( 'fontawesomejs', '//use.fontawesome.com/0a1b8c9dce.js', array('jquery'), '3.3.4', true );
wp_enqueue_script( 'audioplayer', get_template_directory_uri() . '/js/audioplayer.min.js', array('jquery'), '1.0', true );
wp_enqueue_script( 'actionsjs', get_template_directory_uri() . '/js/actions.js', array('jquery'), '1.0', true );
}
}
add_action('init', 'add_scipts');
function prefix_add_footer_styles() {
wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/style.css',true,'1.1','all');
wp_enqueue_style( 'uniquestylename', '//www.websiteurl.com/css/style.css',true,'1.1','all');
wp_enqueue_style( 'font-awesome', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css',true,'1.1','all');
wp_enqueue_style( 'googlefonts', '//fonts.googleapis.com/css?family=Lato:300,400,700|Oswald:300,400,700',true,'1.1','all');
};
add_action( 'get_footer', 'prefix_add_footer_styles' );
// Remove WP Version From Styles
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Remove WP Version From Scripts
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Function to remove version numbers
function sdt_remove_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
This function properly enqueues remote and local versions of JS and CSS scripts and places them in the footer of the page or where ever one places the <?php wp_footer();?> in your WordPress site. The second part of the script removes their version numbers. The reason for this is that using website optimization sites like tools.pingdom.com, gtmetrix, and google page speed will often suggest removing query strings like the ones generated by WordPress.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.