• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merge .js files to load only "single merged maxi one"

#1
Hi,
I don't know if is the right section but here my problem:

Currently I have many many .js files loaded at startup (often small ones but is useful mantain them separated for better organization and maintenance).

In some enterprise platform like LifeRay, is possibile to have a maxi merged-file or load them separated (for debug purposes) simply adding an option to URL like "?js_fast_load=0".

Apart url parameter.... is maybe possible with CodeIgniter to have a feature like this or maybe you have some other suggestions to mantain separated source code, but load in PROD env only a merged one for performances?

Thank you
Reply

#2
You can use 2 differente templates. One for the development environment, and one for production.
E.g.:

template_dev.php:
PHP Code:
$this->load->view('template/header_dev');
$this->load->view($main_view);
$this->load->view('template/footer_dev'); 

template_prod.php:
PHP Code:
$this->load->view('template/header_prod');
$this->load->view($main_view);
$this->load->view('template/footer_prod'); 

In your controller, you do this:
PHP Code:
$data['main_view'] = 'the_view';
if (
ENVIRONMENT == 'production') {
 
  $this->load->view('template/template_prod',$data);
}
else {
 
  $this->load->view('template/template_dev',$data);


The header_prod.php file must load the merged js file. The header_dev.php file must load the js files separately.
Reply

#3
(12-15-2017, 11:52 AM)Wouter60 Wrote: You can use 2 differente templates. One for the development environment, and one for production.
E.g.:

template_dev.php:
PHP Code:
$this->load->view('template/header_dev');
$this->load->view($main_view);
$this->load->view('template/footer_dev'); 

template_prod.php:
PHP Code:
$this->load->view('template/header_prod');
$this->load->view($main_view);
$this->load->view('template/footer_prod'); 

In your controller, you do this:
PHP Code:
$data['main_view'] = 'the_view';
if (
ENVIRONMENT == 'production') {
 
  $this->load->view('template/template_prod',$data);
}
else {
 
  $this->load->view('template/template_dev',$data);


The header_prod.php file must load the merged js file. The header_dev.php file must load the js files separately.

Yes, thanks... but my issue is "how to auto-merge these files?". As I said, there are several enterprise platoform that do this kind of task beyond load different files
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.