Change firefox homepage programatically

On each start of Firefox the file user.js is read after the file prefs.js, and overrides corresponding settings in prefs.js. If you close and restart Firefox then the current settings are saved in prefs.js, so the lines in prefs.js and user.js will now be the same.

This might be the reason for your problem. To avoid it, perhaps the solution is to also modify prefs.js before the first Firefox call.


I found the way to achieve this was by adding the relevant code to the user.js file of the default profile, as opposed to creating a new profile, this was not required.

Mozilla documentation and even the comments in the prefs.js state that any changes to the file will be overwritten when firefox starts and to use the user.js file.