0
Script file names
why do sites(popular and non-popular Github pages projects) use randomized combination of letters and numbers for the js file names? instead of name like "script.js", or "projectname.js", or "scriptpurpose.js"? why do they not name it descriptively? these were a few of the js files for a page in a dev.to article page: https://assets.dev.to/assets/baseInitializers-b74902d56433062a87f5f1ce74769baf2a1a698772f46952b0ac72bc95c4abfd.js https://assets.dev.to/assets/application-7258612fccf5d56314a6e4ad1898b4f818f474c4bb3485e302428d489a769a17.js https://assets.dev.to/assets/base-9368b2eee5c6f60e55f4954123eb92b55feeb9778c9ca821647503b0438fa505.js So why this kind of name?
3 Respuestas
+ 2
The best thing I could find is that it's most likely related to the version of the file.
Not in base10 but base16.
Interestingly, there's still no definitive "Good naming convention" for files in JavaScript, like there is for the variables in a file.
0
These numbers are not random, and sites use this for some clever engineering reasons. The most important one is cache busting. Browsers cache javascript but when you update your code, you want the browser to load the newer version, not the cached one. The numbers are actually content-based hash and this efficiently adds version to the files.
0
I have no idea about it, but ChatGPT says it's about browser caching(pretty much what Vaibhav said).
When the file name stays the same, your browser often doesn't re-download it, even if it was updated. So it uses an older version of the js file which your browser had cached when you visited the page the last time.
When file name changes, the browser detects that and re-downloads the new script.
Think of it like a box of chocolates with "chocolates" label. If you replace the chocolates with something else and then close the box like before(but still keep the label same), you'd see it and still think it has chocolates.
But if you also change the label, then next time you see it, you'd think "This has been changed, let me check it again".