Why theme scripts.js is not working, how to attach it I started learning Drupal 8 and encountered problem when I wanted to use scripts.js file globally. I am just testing out code to change background color and write something to console, but script file is not working. source/scripts.js is minified to build/scripts.js which is included in libraries.yml and global is included in info.yml. What am I doing wrong? Maybe I don't understand new Drupal 8 Javascript API?

libraries.yml

  global:
  version: VERSION
  css:
    base:
      css/base/base.css: {}
    layout:
      css/layout/layout.css: {}
    component:
      css/components/components.css: {}
    theme:
      css/theme/theme.css: {}
      css/theme/print.css: { media: print }
  js:
    js/modernizr.js: {}
    js/build/scripts.js: {}
  dependencies:
    - core/drupal
    - core/jquery


info.yml

libraries:
  - core/normalize
  - offer42/global


source/scripts.js

(function (Drupal, $, window) {

  // To understand behaviors, see https://www.drupal.org/node/2269515
  Drupal.behaviors.offer42 = {
    attach: function (context, settings) {

      $(context).find('.block-offer42-branding')(function () {
          $(this).css('background-color', '#000');
          console.log("workinh");
      });

      // Execute code once the DOM is ready. $(document).ready() not required within Drupal.behaviors.


      $(window).load(function () {
        // Execute code once the window is fully loaded
      });

      $(window).resize(function () {
        // Execute code when the window is resized.
      });

      $(window).scroll(function () {
        // Execute code when the window scrolls.
      });

    }
  };

} (Drupal, jQuery, this));
What you're trying to do is not valid jQuery code. You missed the .each part. 

So use $(context).find('.block-offer42-branding').each(function () {