Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
2231 Переглядів

Hi, I am developing a custom module to create several pages on a website. Does anyone know how to load a js file for each page? I ask that because If you load on web.assets.frontend 1 file this is executed every time you navigate on every page.

Аватар
Відмінити
Найкраща відповідь

Hi,

One thing you could do is check window.location.href == 'the page url' and then write the functions required for the page, or if there’s a specific class to identify the page, you can find it using jQuery and then write the code inside that.

if($(‘identifier)) {
    function
}

Or you can add the script in the XML so that it only loads when the specific page loads.

Regards

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
жовт. 18
3741
2
груд. 22
6255
5
січ. 22
11877
1
серп. 16
5237
1
трав. 25
8436