WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The WordPress Codex points to an extremely simple way to change the URL of the wp-content directory, which is, adding this in wp-config.php:

define( 'WP_CONTENT_URL', 'http://example.com/wp-content');

And that does the job of serving most of the JavaScript and CSS files on my website from the different domain, except two.


The reason is very clear — these JavaScript files are served from within the wp-includes directory, which is not affected by the aforementioned rule.

So, is there a similar or simple method to have them served from example.com i.e. the domain of my choice? or is unregistering and enqueuing the scripts from a custom URL (done in functions.php) the only way?

share|improve this question
up vote 2 down vote accepted

Okay, I've tried numerous (literally) codes and methods, and failed miserably. So, like I said in the question, the only safe way seems to be re-registering (unregistering and enqueuing) the scripts.

The Scripts:


Should be served from:


Code in functions.php:

function wpse56742_register_script(){

    //Register and enqueue Comment Reply script
    wp_register_script('comment-reply', 'http://example.com/wp-includes/js/comment-reply.js', false, false);
    wp_enqueue_script( 'comment-reply' );

    //Re-register quicktags script
    wp_register_script('quicktags', 'http://example.com/wp-includes/js/quicktags.js', false, false, true);
    wp_localize_script( 'quicktags', 'quicktagsL10n', array(
        'wordLookup' => __('Enter a word to look up:'),
        'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
        'lookup' => esc_attr(__('lookup')),
        'closeAllOpenTags' => esc_attr(__('Close all open tags')),
        'closeTags' => esc_attr(__('close tags')),
        'enterURL' => __('Enter the URL'),
        'enterImageURL' => __('Enter the URL of the image'),
        'enterImageDescription' => __('Enter a description of the image'),
        'fullscreen' => __('fullscreen'),
        'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
        'textdirection' => esc_attr( __('text direction') ),
        'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
    wp_enqueue_script( 'quicktags' );


As for the code used in wp_localize_script, I got it straight from trunk (you can also get it for your WP version, for example, for WP 3.4, the link would be http://core.svn.wordpress.org/tags/3.4/wp-includes/media.php).

FAQ: Why is quicktags.js loaded in the front-end in the first place? Because I am using the plugin — Basic Comment Quicktags

share|improve this answer
cross-posted to: wordpress.org/support/topic/844266 – its_me Jun 29 '12 at 18:50

The function wp_enqueue_script function has an optional second parameter where you can specify a source.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.