1
I try to work with the code in the way that gives me the greatest possible use of what was written, with this, for every feature that I will need to do in javascript/jQuery I control the individual version of each thing with git.
Controlling this individual version, it happens that I end up having many files to be imported on system loading, my upload has a list like this (well summarized):
Masker-0.0.5.js
navigation-0.0.1.js
Validator-0.2.1.js
Tiles-effects-1.0.0.js
Tiles-navigation-1.0.0.js
Including external uploads, and internal third-party uploads, the list is really giant, because only the features related to Bootstrap CSS already give ~30 file-only inclusions. js, not to mention the style sheets.
Going back to my individual files, they are relatively small, averaging 3k of characters.
My current upload in development environment is done with a PHP class:
class local__jsPackages
{
public static function get_packages()
{
$files = '';
$packages = self::packages();
foreach ($packages as $import)
{
$path = $import['path'];
$file = $import['file'];
$version = $import['version'];
$files .= '<script src="' . $path . '/' . $file . '' . $version . '.js"></script>';
}
return $files;
}
private static function packages()
{
$packages = [
//Plugin Bootstrap
'0' => [
'path' => '../theme/admin/assets/global/plugins/bootstrap/js',
'file' => 'bootstrap',
'version' => (string) '.min'
]
//Dentro da array seguem todas as inclusões locais
];
return $packages;
}
}
And when it’s passed to production, I manually group everything into a single giant file, that’s the part of the problem process.
What is the best way to LOAD many javascript files/methods/plugins ?
PS: They should be loaded all at once, as the application should not allow the user to update the page without scrolling.
'The application must not allow the user to update the page without displaying', ?
– Felipe Duarte
The 'F5' button has been disabled, when the user presses 'F5' the system asks to be logged out, and if it updates by the browser has to log in again.
– AnthraxisBR
I get it, let’s let someone else answer more precisely, but in my opinion, front-end loading on the server was a very used method when javascript was not yet so widespread, today there is no reason to do this, probably you have some language addiction (in the case PHP) and ends up using the same, for other purposes.
– Felipe Duarte
I really have this 'problem' with PHP, I hate to program front-end, and I end up generating a simple 'button' with a PHP class, this is one of the reasons why I don’t know how to operate very well with JS.
– AnthraxisBR
Normal kk, server front-end approach today only in frameworks like ruby on Rails and other derivatives, in Rails for example you generate a crud with the whole front-end schema in minutes, without needing to put your hand in html, only in css to give a 'color' dps, by the way today there are already PHP frameworks that match Rails, I can’t tell you which, but I heard this from the masters https://hipsters.tech/a-vez-do-ruby-on-rails-hipsters-52/
– Felipe Duarte