javascriptlaravellaravel-backpack

Laravel Backpack not reflecting changes made to JS file on page refresh


Code based changes made to the javascript file that I am calling in setupCreateOperation() is not reflecting the changes made on page refresh.

    protected function setupCreateOperation(){
       Widget::add()->type('script')->content(asset('asset/user.js'));
       CRUD::setCreateView('users/create');
    }

enter image description here

Attempted Solution

To add "versioning" to the JS file

Widget::add()->type('script')->src(asset('asset/user.js?v=' . time()));

However this results in the javascript file no longer being called and with there also being no errors when inspecting the browser.

enter image description here


Solution

  • Laravel backpack already handles the "versioning" of the js files as can be seen by the random characters added after user.js.

    enter image description here

    The changes were not reflected because the browser was still referring to the cached js file. Need to do hard refresh of browser rather than regular refresh

    enter image description here