0

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');
mikebrsv
  • 1,890
  • 2
  • 24
  • 31

2 Answers2

0

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.

Jako
  • 832
  • 5
  • 11
  • The file is uploaded to the url via ftp and is there, but I can't access it in my browser. Yet I can access via browser other js files that have been in the same directory before. The script is readable, tried changing permissions up to 777. – mikebrsv Jul 17 '18 at 11:17
0

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');

Tom
  • 1