Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require.js Not Updating in Browser

I am having some issues developing an application with require.js. Whenever I edit a javascript file and save it in my code editor, the browser doesn't seem to register the change. I can refresh the page, but it still runs the old code. The problem is fixed by closing the tab and going re-opening the page, but there must be an easier way to do this. Has anyone else ever had this problem, and how did you fix it?

Thanks in advance!

like image 613
user1318416 Avatar asked Feb 19 '23 10:02

user1318416


1 Answers

Add this to the file that you specify as data-main (in most cases, main.js). Add this at the very first line:

require.config({
    urlArgs: "ts="+new Date().getTime()
});

Note that this should be removed for production.

like image 146
Austin Avatar answered Feb 22 '23 00:02

Austin