This is my mytheme.libraries.yml file:

      css/style.css: {}

      js/effect.js: {}
    - core/jquery

This is my js/effect.js file:

(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
      alert("Hello World");

I created jquery.js in core folder of my site root. Even if I remove the dependency line from my libraries.yml and remove jquery syntax from my effect.js, I receive nothing on my site.


Most times it's about blanks. The yml files are very picky about this. Looks like your effects.js has 6 blanks instead of four.

And make sure, that you have your global-styling listed in the libraries section of your theme.info.yml.

  • Thank You !!! I was not writing global-styling in my theme.info.yml. It works now, kudos to you man ! Anyways, can you tell me what is blanks you told, in yml files ? – innocent rock Jul 6 '16 at 11:21
  • Your line js/effect.js: {} has six spaces before js. It should only have four. – Mark Conroy Jul 6 '16 at 11:45
  • @MarkConroy does it goes for css/style.css too? – innocent rock Jul 6 '16 at 12:04
  • 1
    @ReesGargi In the case you have above, no. As that is indented under theme which has four spaces. See here: drupal.org/coding-standards/config#whitespace – Mark Conroy Jul 6 '16 at 12:05

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.