jquerydrupaltheming

Drupal jQuery dependency throws error "The website encountered an unexpected error. Please try again later."


I am pretty new to Drupal (8) and it's templating system. I set up a themename.libraries.yml and a themename.info.yml that look like this:

xxx.info.yml:

    name: xxx
    description: theme for xxx
    type: theme
    core: 8.x
    package: Custom
    basetheme: classy
    libraries:
      - xxx/stylesheets
      - xxx/javascript
    regions:  
      content: Content
      pagetitle: Pagetitle
      searchblock: Searchblock

xxx.libraries.yml

    stylesheets:
      css:
        theme:
          css/style.css: {}
          https://fonts.googleapis.com/css?family=Open+Sans: {}
          https://fonts.googleapis.com/css?family=Montserrat: {}
    javascript:
      js:
          js/site.js: {}
          js/sticky.js: {}

This works pretty fine, just like I want it. But when I log out, core-jQuery isn't loaded. So I found out, I have to add:

 dependencies:
          - core/jquery: {}

to make Drupal integrate jQuery for anonymous users. But every time I add the lines dependencies: - core/jquery: {} and clear the cache, The whole site breaks and returns a white screen with:

"The website encountered an unexpected error. Please try again later."


Solution

  • - core/jquery: {} should just be - core/jquery
    Here is an example:

    my_awsome_module:
      version: 1.x
      js:
        js/my_awesome_module.js: {}
      dependencies:
        - core/jquery
        - core/jquery.once