0

I'm responding to a GET request with JSON data (Content-Type application/json; charset=utf-8), but it keeps tacking on this random script to every response and I cannot get rid of it no matter what I do:

37 requests
720.83 kB / 707.49 kB transferred
Finish: 602 ms
DOMContentLoaded: 214 ms
load: 476 ms
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 503 of the JSON data
{"expected_data":"values"}<script>
(function() {
 var ws = new WebSocket('ws://' + window.location.host + 
 '/jb-server-page?reloadMode=RELOAD_ON_SAVE&'+
 'referrer=' + encodeURIComponent(window.location.pathname));
 ws.onmessage = function (msg) {
 if (msg.data === 'reload') {
 window.location.reload();
 }
 if (msg.data.startsWith('update-css ')) {
 var messageId = msg.data.substring(11);
 var links = document.getElementsByTagName('link');
 for (var i = 0; i < links.length; i++) {
 var link = links[i];
 if (link.rel !== 'stylesheet') continue;
 var clonedLink = link.cloneNode(true);
 var newHref = link.href.replace(/(&|\?)jbUpdateLinksId=\d+/, "1ドルjbUpdateLinksId=" + messageId);
 if (newHref !== link.href) {
 clonedLink.href = newHref;
 }
 else {
 var indexOfQuest = newHref.indexOf('?');
 if (indexOfQuest >= 0) {
 // to support ?foo#hash 
 clonedLink.href = newHref.substring(0, indexOfQuest + 1) + 'jbUpdateLinksId=' + messageId + '&' + 
 newHref.substring(indexOfQuest + 1);
 }
 else {
 clonedLink.href += '?' + 'jbUpdateLinksId=' + messageId;
 }
 }
 link.replaceWith(clonedLink);
 }
 }
 };
})();
</script>

Does anyone know where this script is coming from and how I can disable it? I've also tried disabling the debugger in both my browser and in PhpStorm.

I've searched high and low and I know it has something to do with "live edit", but I cannot find any options to enable/disable it no matter where I look.

hakre
199k55 gold badges453 silver badges865 bronze badges
asked Aug 25 at 22:18
2
  • 1
    Not sure why this is closed. It fits the parameters: 3. software tools commonly used by programmers; and is a practical, answerable problem that is unique to software development. Commented Aug 27 at 8:28
  • Found another answer that may be more straight forward / useful to know about when setting up the project in the IDE "more completely": stackoverflow.com/a/79752335/367456 Commented yesterday

3 Answers 3

3

Does anyone know where this script is coming from and how I can disable it? I've also tried disabling the debugger in both my browser and in PhpStorm.

To prevent the <script> tag related to the RELOAD_ON_SAVE feature by IntelliJ (also for PhpStorm), open the Settings (Menu: File > Settings... – Keyboard: Ctrl+Alt+S) and disable the Reload behavior section's Reload page in browser by setting the drop-down to "Disabled" under Tools > Web Browsers and Preview.

the Reload behavior setting Reload page in browser by setting the drop-down to "Disabled"

Restart PhpStorm for that setting to take effect, e.g. Menu: File > Invalidate Caches ...; Then click the Just restart link.

the Just restart link

It will get rid off the reload script that injects the web socket connection, however some query parameters will retain:

before: http://localhost:63342/project/index.html?_ijt=prpu...fj1m&_ij_reload=RELOAD_ON_SAVE
after: http://localhost:63342/project/index.html?_ijt=2gef...nbc5

Checked against PhpStorm 2025年2月1日 RC Build #PS-252.25557.79, built on August 21, 2025.

answered Aug 26 at 5:45
2

I've found the cause. PHPStorm adds these parameters when you open the index page via ALT+F2:

?_ijt=pdprfcc6u90jpqpfgc0hfk2mk3&_ij_reload=RELOAD_ON_SAVE

My code automatically preserves URL parameters, so this was causing the devenv to return the extra payload.

answered Aug 25 at 22:33
2
  • No idea why someone would downvote this, it seems like useful info, +1 to counter the downvote. You could expand your answer a bit to describe why you might use ALT+F2, which might make it easier to find for future visitors. Commented Aug 25 at 23:13
  • 1
    @Don'tPanic: Also no clue, however there is a setting to deactivate this specific behaviour in the IDE - I've left an answer that should add more keywords for future searches: stackoverflow.com/a/79746445/367456 Commented Aug 26 at 6:08
0

Does anyone know where this script is coming from and how I can disable it? I've also tried disabling the debugger in both my browser and in PhpStorm.

The overall behaviour can be completely 1 prevented by adding a webserver to your project configuration (Menu: Tools -> Deployment -> Confguration...).

Once set up, e.g. type Local or mounted folder, PhpStorm opens according to your projects path <-> browser mappings.


1 an alternative variant to the existing answer that is about controlling/setting the RELOAD_ON_SAVE behaviour.

answered yesterday

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.