WordPress.org

Ready to get started?Download WordPress

Forums

Unexpected token ILLEGAL, even on clean install (7 posts)

  1. pereirinha
    Member
    Posted 1 year ago #

    Hi all:

    I've been working on a new project and while been working on the front-end, I didn't had any problem.
    However, I start noticing that some features on the back office (like slide down menus) weren't working. So I fired up debugging console of my browser and found that there is an intermittent issue:

    Uncaught SyntaxError: Unexpected token ILLEGAL load-scripts.php:1
    load-scripts.php?c=1&load%5B%5D=jquery,utils,json2&ver=3.5.1:1

    other times...

    Uncaught SyntaxError: Unexpected token ILLEGAL load-scripts.php:1
    Uncaught ReferenceError: jQuery is not defined load-scripts.php:2
    (anonymous function)

    Similar issues found in different browsers: Chrome, Safari and Firefox.

    Next step was googling for some answers and found a reference for javascript diagnose here. When I enable SCRIPT_DEBUG, the error stops, and everything runs smoothly again.

    At this moment I don't have any plugin nor theme installed and been running in localhost.

    Couldn't find yet a solution. Any ideas?

  2. EXYST
    Member
    Posted 1 year ago #

    Hi,
    I have the same issue with WordPress 3.5.1, showing me this Javascript syntax error, unexpected token illegal. What I found is a bug present in the current WP version concerning unnecessary BOM marks in UTF-8 encoded scripts: http://core.trac.wordpress.org/ticket/23315.

    There is a UTF-8 BOM in ./wp-includes/js/jquery/jquery.query.js which you have to remove. You need an appropriate text editor like Notepad++ or UltraEdit and encode/save the file without BOM.

    Nevertheless it didnt work for me so far. There are other complaints about this WordPress bug on the internet too.

    Regards

  3. EXYST
    Member
    Posted 1 year ago #

    ... continued ...

    After my first attempt I also checked some other javascript files in WordPress, especially those provided by plugins. I found scripts with different file formats like ANSI, UTF, etc. I didnt find another UTF8 BOM in a file, but I disabled a plugin and the problem was gone.

    I suppose this load-scripts error can appear in various situations, so there might not be a single way of solution. But the first thing I would check is the script files involved. Since load-scripts.php is concatenating several javascripts needed on a certain page they should definitely have a proper (and similar?) file format and encoding.

  4. pereirinha
    Member
    Posted 1 year ago #

    Hi Exyst,

    Thank you for bringing an explanation on this matter, as I haven't fount that one before.

    Regarding this, I think the errors stop appearing and I'm not sure if was something that i did. However, if I remember this issues occurred only on local installation. Once on production server i've stop getting those.

    I've been using 3.6 beta and it seems that this problem is fixed... at least on my local environment. ;)

  5. riteshonline
    Member
    Posted 10 months ago #

  6. riteshonline
    Member
    Posted 10 months ago #

    PLEASE HELP ME

  7. TNTMAX
    Member
    Posted 10 months ago #

    OK, This is what I found to be the issue, the load_scripts.php is adding slashes to some quoted elements when loading the scripts, so wrap the last "echo $out" (line 161) with "echo utf8_encode(stripslashes($out));" that solved my problem!

Topic Closed

This topic has been closed to new replies.

About this Topic