0

is it possible to load JS and CSS files in JSF pages without mentioning them using <link> or <script>.

I want to dynamically load the css and js, so that I can avoid writing so much code.

Blazemonger
  • 90,923
  • 26
  • 142
  • 180
Manju
  • 151
  • 1
  • 4
  • jQuery has a [`getScript()`](https://api.jquery.com/jquery.getscript/) method specifically to do this; you could [read its source](http://james.padolsey.com/jquery/#v=1.11.2&fn=jQuery.getScript) and use a similar technique. I believe it basically loads a `.js` file using AJAX and `eval()` it immediately. – Blazemonger Jun 01 '16 at 16:37
  • That said, you'd definitely be writing MORE code by loading these files dynamically than if you simply linked to them in the JSF file. – Blazemonger Jun 01 '16 at 16:41
  • Another related question: http://stackoverflow.com/q/8367421 – BalusC Jun 01 '16 at 17:37
  • Thanks Blazemonger and BalusC. – Manju May 11 '17 at 11:00

0 Answers0