1

I’m using Drupal 8.5.4 and I have installed the Advanced CSS/JS Aggregation module. I’m trying to install the Waypoints plugin without success via the module: jQuery waypoints (still on alpha1 for D8). Is there a way to simply install the plugin manually?

1

Yupp, simply download the Waypoints library, extract and rename the folder to just waypoints, then put it into themes/custom/MYTHEME/libs or into modules/custom/MYMODULE/libs and follow one of the following instructions:

Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme

Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module


Basically all you have to do is to create the corresponding MYTHEME/MYMODULE.libraries.yml file

waypoints:
  js:
    libs/waypoints/lib/jquery.waypoints.min.js: {}
  dependencies:
    - core/jquery

and then attach the library to all pages via hook_page_attachments() or hook_page_attachments_alter() inside the MYTHEME.theme or MYMODULE.module file.

<?php

function MYTHEME/MYMODULE_page_attachments_alter(&$attachments) {
  $attachments['#attached']['library'][] = 'MYTHEME-or-MYMODULE/waypoints';
}

Your Answer

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

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