I try to add to my custom wordpress Theme requirejs because I do not want to use wp_enqueue over and over to inject used plugins and on the other side I do not want to mess the DOM from the beginning.

I followed a lot of tutorials what I got from google but none of theme is working. Is there a good working example how to use requirejs in a wrodpress theme properly?

  • I haven't ever used require in a WordPress project, but, you might try something like using grunt concatenation/minification so you can use a lot of js files for development, but only have to do a single wp_enqueue_script in your functions.php (or wherever). That's what I usually do anyway if I'm doing a project that is going to be js heavy (for WordPress anyway). Apr 24, 2015 at 1:25
  • Between I managed like adding manually require.js to the footer and call the main file over requires config file.
    – fefe
    Apr 24, 2015 at 7:54
  • You enqueue requirejs as one file, then your main entry file as another with the requirejs dependency.
    – kontur
    Oct 15, 2017 at 18:49


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.