Function __global->javascript_enforce

Definitions

sources/web_resources.php

  • Force a JavaScript file to be cached (ordinarily we can rely on this to be automated by require_javascript/javascript_tempcode).
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$j string No No required parameter N/A N/A The JavaScript file required
$theme ?ID_TEXT No No Null N/A N/A The name of the theme (null: current theme)
$allow_defer boolean No No False N/A N/A Allow the compilation to be deferred through a PHP call (useful for parallelising compilation)

Returns

  • The path to the JavaScript file in the cache (blank: no file) (defer: defer compilation through a script; only possible if $allow_defer is set)
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Force a JavaScript file to be cached (ordinarily we can rely on this to be automated by require_javascript/javascript_tempcode).
 *
 * @param  string $j The JavaScript file required
 * @param  ?ID_TEXT $theme The name of the theme (null: current theme)
 * @param  boolean $allow_defer Allow the compilation to be deferred through a PHP call (useful for parallelising compilation)
 * @return string The path to the JavaScript file in the cache (blank: no file) (defer: defer compilation through a script; only possible if $allow_defer is set)
 */

function javascript_enforce(string $j, ?string $theme = null, bool $allow_defer = false) : string