# \CGExtensions\jsloaderjsloader

A utility class to manage loading and combining javascript libraries and associated stylesheets.

## Summary

Methods
Properties
Constants
register()
unregister_by_module()
require_lib()
require_jsext()
add_jsfile()
add_js()
add_cssfile()
add_css()
render()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A
final

File
  lib/jsloader/class.jsloader.php
Class hierarchy
  \CGExtensions\jsloader\jsloader

## Tags

todo |

## Methods

### register()

    register(\CGExtensions\jsloader\libdefn $rec, bool $force)

Register a library definition

#### Parameters

\CGExtensions\jsloader\libdefn | $rec | The library definition to register.
bool | $force | Force the libdefn to be registered even if it already has been.

#

static

## Tags

todo |

### unregister_by_module()

    unregister_by_module(string $module_name)

Unregister all javascript libraries associated with a module.

#### Parameters

string | $module_name |

#

static

## Tags

todo |

### require_lib()

    require_lib(string $name)

For this request, indicate that a javascript library is required.

#### Parameters

string | $name |

#

static

## Tags

todo |

### require_jsext()

    require_jsext(string $url)

Require an external javascript library.

[experimental]

#### Parameters

string | $url |

#

static

## Tags

todo |

### add_jsfile()

    add_jsfile(string $file, string[] $depends)

For this request, add a specified javascript file.

#### Parameters

string | $file | The complete pathname to the javascript file.
string[] | $depends | array of library names (must already be registered) that this file depends upon.

#

static

## Tags

todo |

### add_js()

    add_js(string $code, string[] $depends)

Add javascript code to the output for this request.

#### Parameters

string | $code | The javascript code (script tags are not required)
string[] | $depends | Array of required javascript libraries.

#

static

## Tags

todo |

### add_cssfile()

    add_cssfile(string $file, array $depends)

Add a css file to the output.

#### Parameters

string | $file | The filename. If not an absolute path, then search for the file within the current module directory (if any), the uploads path, and then the root path.
array | $depends | Array of libraries that this css file depends upon.

#

static

## Tags

todo |

### add_css()

    add_css(string $styles, array $depends)

Add static css text to the output.

#### Parameters

string | $styles | The static CSS text (style tags are not needed).
array | $depends | A list of libraries that this css depends upon.

#

static

## Tags

todo |

### render()

    render(array $opts) : string

Render the output javascript and stylesheets into cachable files and output the appropriate HTML tags.

#### Parameters

array | $opts | Options for this method (for further reference, see the {cgjs_render} smarty tag.

#### Returns

string —

HTML output code.

#

static

## Tags

todo |

### class.jsloader.php