How do I enable a custom JS file in my Drupal site? [duplicate]
-
29-09-2020 - |
Vra
In my Drupal themes' folder I've created a file named "custom-js.js".
I created this file to use 2 jQuery manipulations on a small text block that appears in all pages of the site.
My question is, how do I enable this JS file? How do I "link it" with Drupal, so that it's actually being used in my site?
Oplossing
There are several ways to add JS files to Drupal, depending on the requirements.
If the JS is related to your theme and used on every page, perhaps easiest to add the file to your theme's .info
file
create the JS file in mytheme/custom-js.js and configure it for the theme in mytheme.info
scripts[] = js/custom-js.js
Flush all caches to register the new JS file.
More info: https://www.drupal.org/node/756722
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan drupal.stackexchange