Closed (fixed)
Project:
Javascript Aggregator
Version:
5.x-0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
17 Jan 2008 at 14:34 UTC
Updated:
1 Feb 2008 at 18:01 UTC
Jump to comment: Most recent file
Nice idea. Here's a version (attached) that takes a slightly different approach (reads the local files rather than fetching them over HTTP).
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | javascript_aggregator.module.txt | 4.31 KB | derjochenmeyer |
| #6 | javascript_aggregator.module.txt | 4.24 KB | derjochenmeyer |
| js_aggregator.php_.txt | 976 bytes | hickory |
Comments
Comment #1
derjochenmeyer commentedThanks a lot for the response. This is my first try to maintin a module containing functionality that has been useful to myself on many sites and that i want to contribute back, since its often requested. :)
The approach you suggest is more elegant. But there are some drawbacks that i see.
Patterns: In my approach i use the same pattern to search and remove the script files, thus making sure only those get removed that were actually aggregated. E.g. your approach would only aggregate files included with double quotes but remove also files linked with single quotes. Or did i miss something?
install file: It surely makes sense to put the dir creation function into an install file and not run it on every page load. But is it necessary? I dont know enough about performance of this function.
Regarding this
if (!file_exists($js_file)){ // FIXME: check if source files have changed, or empty folder if cache is cleared:What i wanted to do is create an admin page with a "clear aggregated javascript files". Including Admin menu integration.
Comment #2
derjochenmeyer commentedbtw, thanks a lot for this hint:
it solves this issue i guess: http://drupal.org/node/211061
Comment #3
hickory commentedRe: "would only aggregate files included with double quotes but remove also files linked with single quotes"
It would probably be easy to alter the regular expression to match single quotes as well. Is this necessary though? Presumably all scripts added with drupal_add_js use double quotes - can anything else get into $scripts?
There should be an admin box on the 'performance' page to switch JS aggregation on and off: if it's on, then there would ideally be a way to remove the cached .js files in the same way that aggregated CSS files are refreshed at the moment.
Might as well put those two lines in an install file if you can, rather than running them on every page load.
Comment #4
derjochenmeyer commentedYou're right, probably not :-) But it would be "failsave then"... i just know that one of the gmap modules outputs the include with singlequotes, but thats in $head.
Thats anoter thing i want to make sure. That the file is not an external file.
To put the on/off option on the 'performance' page is a good idea, thanks!
Do you see any way to get rid of the page.tpl.php modification? I guess i cant modify phptemplate variabels in a module because phptemplate is run after all modules, right?
Comment #5
hickory commentedI can't think of a way to avoid editing page.tpl.php, but I don't think that's a big problem.
The $scripts variable is generated from drupal_get_js in the phptemplate_page function, but you don't want to be overriding all that, I don't think, even if it was possible.
Comment #6
derjochenmeyer commentedThanks a lot for your suggestions!
I created a new fieldset on the Performance page to disable/enable the js aggregation. I also added a menu callback and a link to clear the js cache. (access only for user 1 at the moment).
I did NOT move the files/js creation to an install file, similar to the core css aggregation its still in the main function (http://drupal.org/node/149402).
Ill update CVS later today.
Comment #7
derjochenmeyer commentedSome more changes and error fixes.
Comment #8
derjochenmeyer commentedComment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.