Automatically use the minified version of the JS files in prod, while
still using the full versions (for easy debugging) in dev.
Patch by fu.
diffs (123 lines):
diff -r a0d31dfd13b5 -r 05c6a83eaf56 cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm Tue Apr 19 16:48:51 2011 +0800
+++ b/cgi-bin/LJ/S2/EntryPage.pm Tue Apr 19 16:52:31 2011 +0800
@@ -87,7 +87,7 @@ sub EntryPage
));
LJ::need_res( { group => "jquery" }, qw(
- js/jquery/jquery.ui.widget.min.js
+ js/jquery/jquery.ui.widget.js
js/jquery.quickreply.js
js/jquery.threadexpander.js
) );
@@ -382,11 +382,11 @@ sub EntryPage
LJ::need_res( "js/commentmanage.js" );
LJ::need_res( { group => "jquery" }, qw(
- js/jquery/jquery.ui.widget.min.js
+ js/jquery/jquery.ui.widget.js
js/jquery.ajaxtip.js
js/jquery.commentmanage.js
- js/tooltip.min.js
- js/tooltip.dynamic.min.js
+ js/tooltip.js
+ js/tooltip.dynamic.js
stc/ajaxtip.css
stc/popup-form.css
) );
diff -r a0d31dfd13b5 -r 05c6a83eaf56 cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl Tue Apr 19 16:48:51 2011 +0800
+++ b/cgi-bin/ljdefaults.pl Tue Apr 19 16:52:31 2011 +0800
@@ -336,6 +336,27 @@ no strict "vars";
# (as they should be) some pages look weird.
# So let us temporarily force old behavior on existing files
$LJ::OLD_RES_PRIORITY = 5;
+
+ # we only support the minifaction of a subset of pre-generated files
+ # so for now, let's just configure which files to use a minified version of
+ # TODO: minify as part of the build process, and remove this hardcoding
+ %LJ::MINIFY = (
+ "js/jquery/jquery-1.5.js" => "js/jquery/jquery-1.5.min.js",
+ "js/jquery/jquery.ui.core.js" => "js/jquery/jquery.ui.core.min.js",
+ "js/jquery/jquery.ui.autocomplete.js" =>
"js/jquery/jquery.ui.autocomplete.min.js",
+ "js/jquery/jquery.ui.datepicker.js" =>
"js/jquery/jquery.ui.datepicker.min.js",
+ "js/jquery/jquery.ui.dialog.js" =>
"js/jquery/jquery.ui.dialog.min.js",
+ "js/jquery/jquery.ui.draggable.js" =>
"js/jquery/jquery.ui.draggable.min.js",
+ "js/jquery/jquery.ui.droppable.js" =>
"js/jquery/jquery.ui.droppable.min.js",
+ "js/jquery/jquery.ui.mouse.js" =>
"js/jquery/jquery.ui.mouse.min.js",
+ "js/jquery/jquery.ui.position.js" =>
"js/jquery/jquery.ui.position.min.js",
+ "js/jquery/jquery.ui.selectable.js" =>
"js/jquery/jquery.ui.selectable.min.js",
+ "js/jquery/jquery.ui.sortable.js" =>
"js/jquery/jquery.ui.sortable.min.js",
+ "js/jquery/jquery.ui.widget.js" =>
"js/jquery/jquery.ui.widget.min.js",
+
+ "js/tooltip.js" => "js/tooltip.min.js",
+ "js/tooltip.dynamic.js" => "js/tooltip.dynamic.min.js",
+ ) unless defined %LJ::MINIFY;
}
diff -r a0d31dfd13b5 -r 05c6a83eaf56 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl Tue Apr 19 16:48:51 2011 +0800
+++ b/cgi-bin/ljlib.pl Tue Apr 19 16:52:31 2011 +0800
@@ -1310,9 +1310,7 @@ sub start_request
LJ::need_res( { group => 'jquery', priority => $LJ::LIB_RES_PRIORITY },
# jquery library is the big one, load first
- $LJ::IS_DEV_SERVER ?
- 'js/jquery/jquery-1.5.js' :
- 'js/jquery/jquery-1.5.min.js',
+ 'js/jquery/jquery-1.5.js',
# the rest of the libraries
qw(
diff -r a0d31dfd13b5 -r 05c6a83eaf56 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Tue Apr 19 16:48:51 2011 +0800
+++ b/cgi-bin/weblib.pl Tue Apr 19 16:52:31 2011 +0800
@@ -2460,8 +2460,9 @@ sub need_res {
foreach my $reskey (@_) {
die "Bogus reskey $reskey" unless $reskey =~ m!^(js|stc)/!;
- $reskey =~ s/\.(js|css)$/.min.$1/
- if $opts{optimize} && ! $LJ::IS_DEV_SERVER;
+ my $resinclude;
+ $resinclude = $LJ::MINIFY{$reskey} unless $LJ::IS_DEV_SERVER;
+ $resinclude ||= $reskey;
# we put javascript in the 'default' group and CSS in the 'all' group
# since we need CSS everywhere and we are switching JS groups
@@ -2469,7 +2470,7 @@ sub need_res {
unless ($LJ::NEEDED_RES{$lgroup}->{$reskey}++) {
$LJ::NEEDED_RES[$priority] ||= [];
- push @{$LJ::NEEDED_RES[$priority]}, [ $lgroup, $reskey ];
+ push @{$LJ::NEEDED_RES[$priority]}, [ $lgroup, $resinclude ];
}
}
}
diff -r a0d31dfd13b5 -r 05c6a83eaf56 htdocs/talkread.bml
--- a/htdocs/talkread.bml Tue Apr 19 16:48:51 2011 +0800
+++ b/htdocs/talkread.bml Tue Apr 19 16:52:31 2011 +0800
@@ -215,7 +215,7 @@ body<=
) );
LJ::need_res( { group => "jquery" }, qw(
- js/jquery/jquery.ui.widget.min.js
+ js/jquery/jquery.ui.widget.js
js/jquery.quickreply.js
) );
@@ -720,11 +720,11 @@ body<=
if ($do_commentmanage_js) {
LJ::need_res('js/commentmanage.js');
LJ::need_res( { group => "jquery" }, qw(
- js/jquery/jquery.ui.widget.min.js
+ js/jquery/jquery.ui.widget.js
js/jquery.ajaxtip.js
js/jquery.commentmanage.js
- js/tooltip.min.js
- js/tooltip.dynamic.min.js
+ js/tooltip.js
+ js/tooltip.dynamic.js
stc/ajaxtip.css
stc/popup-form.css
) );
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog