Skip to content

Instantly share code, notes, and snippets.

@oquirozm
Created August 10, 2017 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oquirozm/32a0f45ad0213290179b50691bdb5c34 to your computer and use it in GitHub Desktop.
Save oquirozm/32a0f45ad0213290179b50691bdb5c34 to your computer and use it in GitHub Desktop.
A simple gist that has the code to add requirejs to WordPress.
<?php
// How to add require.js to WordPress.
wp_enqueue_script('requirejs', '//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.min.js');
$app_base = get_template_directory_uri() . '/scripts';
wp_localize_script( 'requirejs', 'require', array(
'baseUrl' => $app_base,
'deps' => array( $app_base . '/main.js')
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment