Skip to content
Snippets Groups Projects
Commit 6d3bebff authored by Gerry Weißbach's avatar Gerry Weißbach
Browse files

Add Event to modify the list of javascript files before they are processed....

Add Event to modify the list of javascript files before they are processed. This allows plugins to not have their - or other plugins - script delivered to the client. Creating the list of files upfront might add a little overhead which I think is OK when you can be certain that only JavaScript that really is needed will be delivered to the client.

Multiple Javascript requests, e.g. to only send the jQuery part or just editor/administrator scripts, could be implemented with this modification (I know, jQuery has already been split).
parent 9c5f3115
No related branches found
No related tags found
No related merge requests found
......@@ -36,10 +36,6 @@ function js_out(){
$tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t')));
if(!$tpl) $tpl = $conf['template'];
// The generated script depends on some dynamic options
$cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tpl,'.js');
$cache->_event = 'JS_CACHE_USE';
// array of core files
$files = array(
DOKU_INC.'lib/scripts/jquery/jquery.cookie.js',
......@@ -75,6 +71,13 @@ function js_out(){
}
}
// Let plugins decide to either put more scripts here or to remove some
trigger_event('JS_SCRIPT_LIST', $files);
// The generated script depends on some dynamic options
$cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js');
$cache->_event = 'JS_CACHE_USE';
$cache_files = array_merge($files, getConfigFiles('main'));
$cache_files[] = __FILE__;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment