Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

The ezcss and ezscript operators

Reference for the eight packer operators of ezjscore (ezcss, ezcss_require, ezcss_load, ezcssfiles, ezscript, ezscript_require, ezscript_load, ezscriptfiles) with every parameter, default and behavior.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/theme-design/ezcss-and-ezscript-operators.md

On this page

The ezcss and ezscript operators

This page is a reference for designers and developers. All eight operators are defined by the class ezjscPackerTemplateFunctions in extension/ezjscore/autoloads/ezjscpackertemplatefunctions.php and registered in extension/ezjscore/autoloads/eztemplateautoload.php.

Contents

  1. Signatures
  2. require, load and plain: how they differ
  3. Pack levels
  4. File names
  5. Examples

Signatures

ezscript[_require|_load]( array|string scripts
                          [, string type='text/javascript'
                          [, string language=''
                          [, string charset='utf-8'
                          [, int pack_level=2 ]]]] )

ezcss[_require|_load]( array|string css_files
                       [, string media='all'
                       [, string type='text/css'
                       [, string rel='stylesheet'
                       [, string charset=''
                       [, int pack_level=3 ]]]]] )

ezscriptfiles( array|string scripts [, int pack_level=2 [, bool ignore_loaded=false ]] )
ezcssfiles( array|string css_files [, int pack_level=3 [, bool ignore_loaded=false ]] )

(from the class's header comment; charset on stylesheets is deprecated as not valid HTML.) Arrays may be nested; they are flattened, so ezini() lists can be passed inside an array.

require, load and plain: how they differ

CallBefore any _load ranAfter a _load ran
ezcss_require / ezscript_requireremembers the files (in the view's persistent variable), prints nothingprints the files not printed yet
ezcss_load / ezscript_loadprints its files plus all remembered ones, marks the kind as loadedprints the files not printed yet
ezcss / ezscriptprints its filesprints its files
ezcssfiles / ezscriptfilesreturns URLs of its files (minus already printed ones, unless ignore_loaded)same

Because the remembered files are kept in the persistent variable of the content view, a full view served from the view cache still delivers its required files to the pagelayout.

Pack levels

LevelEffect
0off: every file served on its own
1files merged into one
2merged, whitespace and comments removed (JavaScript and CSS optimizers of ezjscore.ini [eZJSCore])
3same as 2 (deprecated)

The level is forced to 0 when site.ini [TemplateSettings] DevelopmentMode=enabled, unless ezjscore.ini [eZJSCore] Packer is set (to enabled, disabled or a level 0 to 3). Stylesheets: relative url() paths are rewritten to absolute ones when packed, so images and fonts still load.

File names

  • 'main.css': found in stylesheets/ of the design cascade (javascript/ for scripts).
  • 'sub/file.css': a subfolder.
  • '/extension/x/design/y/stylesheets/file.css': a leading / means a path from the installation root, outside the usual subfolder.
  • 'ezjsc::jquery', 'ezjsc::jqueryUI': generators of ezjscore ([ezjscServer_ezjsc] in ezjscore.ini); a name with :: calls a server function instead of reading a file.

A file that is not found is skipped with a warning in the debug output ("Could not find: ..."), not an error.

Examples

{* all stylesheets of the design, plus whatever views required *}
{ezcss_load( array( 'base.css', 'components.css' ) )}

{* merged but not minified: keeps vendor CSS byte-identical *}
{ezcss_load( array( 'vendor.css' ), 'all', 'text/css', 'stylesheet', '', 1 )}

{* jQuery and the site script at the end of the body *}
{ezscript_load( array( 'ezjsc::jquery', 'site.js' ) )}

{* deferred bundle *}
{foreach ezscriptfiles( array( 'late.js' ), 2, true() ) as $url}<script defer src="{$url}"></script>{/foreach}

Note

The starter design calls ezcss_load( ..., 'all', 'text/css', 'stylesheet', 1 ) with five arguments. Read against the signature, the fifth is charset, so the pack level stays at its default. Pass all six arguments (with '' for charset) when you want to set the level.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x