vincent15000's avatar

VSCode and page reloading

Hello,

I have a problem and I think that VSCode is responsible for this problem.

If I want to refresh the content of a page only by handling the DOM, the page shouldn't reload. But it reloads event if the code doesn't dynamically reload the page (no location.href and no reload in the code).

Is it possible that VSCode refreshes the page ?

Thanks for your help.

V

0 likes
8 replies
CamKem's avatar

Why do you think it's VSCode doing the reload? Are you using an inbuilt server plugin for VSCode? If not, I don't see any reason VSCode would have the ability to refresh a page. Why don't you post the code you are trying to view and we can see if there is any issues.

1 like
Snapey's avatar

are you viewing the page in vscode? If. not, then NO

You can always test by quitting vscode if you are not convinced

1 like
vincent15000's avatar

@Snapey

Well in fact I don't use VSCode myself and it's not my code, I help some students (individual mentoring each week) that begin in development, they use for the moment HTML / CSS / JS. And they have to update the content of the view without refreshing the page, but only by handling the DOM.

They are using VSCode and its internal GoLive server to display the page, but I don't really know VSCode, I use rather SublimeText and soon PHPStorm.

Three students have the same problem (but with a different code approach) : while using fetch() to retrieve, update or delete datas via an API, the page refreshes. But they don't have any location.href or document.reload() in their code and all the events callbacks contain a preventDefault().

So I assume that VSCode could be responsible for this refresh.

Snapey's avatar

@vincent15000 I can understand the browser refreshing when the code is updated, but not when an ajax call is used.

Actually, my impression is that this is for static content so I'm puzzled what is serving the background ajax requests?

If they are using Laravel as the backend, could it be that the go live server is monitoring storage folders so any change to logs or cache or view caches makes the server think it needs to hot-reload. There is a setting in the plugin;

    "liveServer.settings.ignoreFiles": [
        
        ".vscode/**",
        "**/*.scss",
        "**/*.sass",
        "**/*.ts"
    ],

it would be worth adding the storage folder to the exclusions array if this is the case,

1 like
vincent15000's avatar

@Snapey Thank you, that's probably the reason, effectively there is quite each time a new file added to a folder or a file deleted from the folder. I will check that.

To answer your question, the ajax request is because the website retrieves the data from an API developed with nodejs in the backend.

Snapey's avatar

@vincent15000 ok , so node backend perhaps updates a file that is being watched by the golive server

1 like
vincent15000's avatar

@Snapey I tell you soon if it's effectively this problem or not. But it really seems to be that.

vincent15000's avatar

@Snapey Unfortunately it wasn't this problem (and I don't have identified the problem yet).

Please or to participate in this conversation.