I have a custom module which has a javascript file. Here’s the content of the javascript file:
(function ($ , Drupal) { Drupal.behaviors.promotionalOverlayBlock = { attach: function(context, settings) { console.log("hello world") } }; })(jQuery, Drupal);
The location of javascript file:
mymodule/js/overlayblock.js
In my mymodule.libraries.yml
file it has the following:
mymodule: js: js/overlayblock.js: {} dependencies: - core/jquery - core/jquery.once - core/drupalSettings
When I load my drupal page, I expecting to see the “hello world” in the browser console. However, nothing show up. I view the page html code and search for my javascript there, but I can’t seems to find anything related to my javascript file.
What could be the problem here?