imathis / octopress

Octopress is an obsessively designed framework for Jekyll blogging. It’s easy to configure and easy to deploy. Sweet huh?
http://github.com/imathis/octopress
9.32k stars 2.62k forks source link

minify_and_combine should always include jquery first #638

Closed jlgoolsbee closed 11 years ago

jlgoolsbee commented 12 years ago

The new "minify_and_combine" rake task should always add jquery to the output file first; right now it appears to pull them in alphabetically – which works fine until you add a .js file that starts with something alphabetically before "jquery".

pferreir commented 12 years ago

I had that problem using the 2.1 branch, as jQuery was being put at the end of the minified file.

The following change solves the issue:

diff --git a/Rakefile b/Rakefile
index 7a3eec8..9e2f3b3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -67,12 +67,15 @@ Rake::Minify.new(:minify_and_combine) do

   puts "BEGIN Minifying #{output_file}"
   group(output_file) do
+    add("#{source_dir}/javascripts/group/jquery.min.js")
     files.each do |filename|
-      puts "Minifying- #{filename} into #{output_file}"
-      if filename.include? '.min.js'
-        add(filename, :minify => false)
-      else
-        add(filename)
+      if !filename.include? 'jquery.min.js'
+        puts "Minifying- #{filename} into #{output_file}"
+        if filename.include? '.min.js'
+          add(filename, :minify => false)
+        else
+          add(filename)
+        end
       end
     end
   end
wetty commented 11 years ago

In my opinion this problem does not exist anymore in 2.1 because the jquery.js is loaded separately from googleapis.com now and no longer included in the minify and combine process. Beside that it seems to be possible to define the order of javascripts in the require-js.yml config file.

imathis commented 11 years ago

You may not be up to date. Now there is a way to set load order in the config yaml. And yes you're right @wetty we're using jquery from the Google CDN right now.

wetty commented 11 years ago

Brandon Mathis schrieb:

Now there is a way to set load order in the config yaml

Is this in require-js.yml, as i mentioned?