Modx revo regClientStartupScript 404

78 views Asked by At

I create a snippet called myscripttest:

<?php
$modx->regClientStartupScript('assets/templates/js/myscript.js');

put myscript.js into assets/templates/js, call [myscripttest] from my document. Result: it returns 404 for assets/templates/js/myscript.js. Same after I clear cash.

But if I include default scripts via this snippet, everything works.

EDITED:

Nothing changes when I add a slash:

<?php
$modx->regClientStartupScript('/assets/templates/js/myscript.js');
2

There are 2 answers

0
Tom On

Load the full url to the script in your browsers address bar. If it show up use your configs' assets path:

$modx->regClientStartupScript(MODX_ASSETS_PATH . 'templates/js/myscript.js');

1
Jako On

Please look in the browser console, which url path is used to access the file. Is the file located there? If yes: Is the script file readable by apache/nginx? If not to assign 644 as file permissions.