queue_js_url — Add a JavaScript file to the current page by URL.

Asset-related functions

Summary

queue_js_url($url, $options = array())

Add a JavaScript file to the current page by URL.

The script link will appear in the head element. This needs to be called either before head() or in a plugin_header hook.

Parameters:
  • $url
  • $options (array) – An array of options.

Usage

Examples

Use to load external javascript files, such as the jquery library. Combine with head_js() to add the links to the page head.

<?php queue_js_url('//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'); ?>

<?php head_js(); ?>