未捕获的SyntaxError:意外的令牌ILLEGAL load-scripts.php:1

I'm developing a wordpress plugin locally using:

  • MAMP (updated to PHP 5.4.4)
  • PhpStorm
  • Chrome

I've turned off short tag, magic quotes and zlib compression, but occasionally load-scripts.php comes back all gibberish:

Broken page

The admin area has no styling, and none of the scripts on the page load or work.

Occasionally, though they do work with a few hard refreshes ( shift + cmd + r )

I've seen a few similar examples and tried their fixes, to no avail (hence disabling short tags, magic quotes and zlib compression).

I've tried it in Firefox, and it breaks ... but when I hard-refresh the page a few times, the issue goes away.

I cannot replicate the issue in Safari.

I had the same issue. Deleting my cookies from that domain and clearing my cache fixed it.

Please clean your browsers cache and delete all cookies. Also disable any caching on your localhost webserver installation.

From what you describe, I'd assume this is apache webserver caching and it does this because you once had compression enabled, something PHP might have done transparently before you configured it not to.

Look into your webservers manual and deactivate any caching. Any. That is important for debugging the issue.

Also disable anything that might set headers to tell the browser that it's okay to cache something in the browser cache. See your webservers' manual and disable anything such.

If the webserver had already cached those responses, you can reload how much you want, you will always see that but not in case repetitive reloading de-actives caching for the one or other request.

The issue, as hakre points out, is almost certainly the cache setting in MAMP. You need to disable it by going to MAMP > Preferences > PHP and set Cache to '--'. Restart MAMP, clear your browse cache and cookies and reload the page.

Re-uploading the entire wp-includes directory fixed the problem for me.

Simply restarted my Mamp web server and it fixed the issue.

I also emptied my browser cache and deleted cookies but that didn't help.

In my case, the error was showing up when I was trying to save a DOMDocument (file) in a folder that wasn't there. I was trying to do something like this:

$xml->save("TEMP/test.xml");

But the folder TEMP wasn't there thus the error was pomping up.

Saving the file to the current directory (e.g. $xml->save("test.xml"); fixed the issue.

While you have those dev tools open, if you click and hold the refresh button, some extra options should appear. None of the other solutions here worked for me, but the Empty Cache and Hard Reload option in that drop-down cleared it up.