CodeIgniter Forums
Clean Javascript integration in CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Clean Javascript integration in CI4 (/showthread.php?tid=75170)



Clean Javascript integration in CI4 - imabot - 01-03-2020

I use a lot of JavaScript on my sites, and with CI3, it is always a problem to add the JS in the views. 
  • I'm sending a list of JS files from the controller,
  • Looping the list to add the JS files in the views
  • Doing it twice if JS files are loaded in the head and in the body section
  • Creating another view if some PHP variables must be sent to JS

It would be nice in future versions to add something allowing smart integration of JS files in the view. I'm not sure what should be done, neither how it should be done, but with CI3, I don't have the feeling of doing something very nice.


RE: Clean Javascript integration in CI4 - MGatner - 01-07-2020

I don't know if this will ever be a part of the framework itself, but check out this module that does what you are requesting:

https://github.com/tattersoftware/codeigniter4-assets


RE: Clean Javascript integration in CI4 - imabot - 01-07-2020

(01-07-2020, 12:38 PM)MGatner Wrote: I don't know if this will ever be a part of the framework itself, but check out this module that does what you are requesting:

https://github.com/tattersoftware/codeigniter4-assets

Thank you. I don't understand clearly what assets are. But it sounds nice. I'll have a deeper look at it in when CI4 will be ready for production.


RE: Clean Javascript integration in CI4 - MGatner - 01-07-2020

Assets are typically JavaScript scripts, CSS stylesheet files, and images (though they could be a lot of things). That assets module covers JavaScript which seems to be your area of interest.