jLoad - Javascript loader library |
[eluser]fatnic[/eluser]
OK. Not sure if this has been done before but here it is anyway. jLoad is basically a library to help load required javascript files quickly into a view. You can download the zip here First you need the jLoad config file. Here is where you set the path to your javascript files, set autoloading files and groups of files. Code: // Javascript path Then to use the library ensure you place the following in the head of your view file. Code: <?php if (isset($javascript)) echo $javascript; ?> Then in your controller you can use Code: // Load the library (autoloading scripts added) Now all the required script tags will automatically be inserted into your view. Anyway, like I said, this has probably been done before but it's something I needed and cooked up quickly. Thought I would share. ![]() Feel free to comment or suggest some ways to make it better. I've not been using CI long and could do with some tips. Cheers.
[eluser]Bramme[/eluser]
it's a nice thing, but your library's purpose alone has been covered in the Colin Williams' template library, which I like a lot. I personally think people who would need something like this, would already use some sort of template library and thus not really need it... Nice job none the less! Edit: one little idea: make sure your $javascript variable is an empty string when the library's loaded but no js files, that way, people don't have to use the isset() part.
[eluser]fatnic[/eluser]
Wow. That's a pretty useful template library! I've just scanned the user guide and it looks very comprehensive. I've taken on-board your comment about the $javascript variable too. Thanks for your input. Much appreciated.
[eluser]Sarre[/eluser]
Hi, I've changed it a bit to allow for dynamically loading scripts. If you have a javascript-heavy site, this will append the scripts to the dom. It makes the site "feel" faster, as you can start surfing as soon as the dom is loaded, and before the scripts are loaded. The library: Code: <?php In the config file, just add: Code: $config['javascript_dynamic'] = true; Greetz
[eluser]Jamie Rumbelow[/eluser]
Nice, but what might be a good idea would be to include a library function that does all the conditionals and outputs the html. Otherwise, simple idea executed well! Cool! |
Welcome Guest, Not a member yet? Register Sign In |