Javascript

Decoupled Drupal, GraphQL and React

Decoupled Drupal is gaining increased interest.  Decoupling refers to using Javascript for the front end of the website and Drupal for the back end content.  Many of the tutorials leave out critical information and even quite recent tutorials are already out of date because the software is changing so quickly.  Developing a production website under these conditions is still risky but has intriguing possibilities.  Javascript avoids page reloads and promises increased speed and separation of the display from the data.  But building a display yourself loses things lik

Where has basePath gone in Drupal 8?

Javascript code in Drupal 7 used drupal_add_js() to attach Javascript code to a webpage.  The Javascript code then used Drupal.settings.basePath to prepend the path to the Drupal installation.  For Drupal installed in the root directory, Drupal.settings.basePath is just the string '/' but if Drupal is installed in a subdirectory then this is necessary for the Javascript code to continue to work.  The php part is

drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js');

and the Javascript part is