Rails 3.2 Asset Pipeline + html5shiv.JS in providers / assets / javascript

After reading this post (recommended reading) that you are not using HTML5Shiv directly from the source, like (almost) everyone does, I try to enable html5shiv.js in my application using the Rails 3.2 Asset Pipeline.

I downloaded both reduced and non-minified versions of javascript. The agreement says that you add third-party files to the vendors / assets folder. I have two questions:

1) Which version (reduced or not indexed) should be added to the vendors / assets / javascrip folder?

2) Since this is a conditional link <!--[if lt IE 9]>, what should I call the script?

I do not want to add it to the manifest of the .js application, because I want to save it as a separate file, and I want to use this condition. I am lost!

Any help would be greatly appreciated.

thank

+5
source share
2 answers

You can use the Unminified version of JS if you want, Rails compresses it in production mode via the pipeline.

To save shiv as a separate file, you can give it your manifest by creating html5.js(or something else) in your directory /vendor/assets/javascripts/. This file requires html5shiv (I assume that the manifest and script are in the same directory).

//= require html5shiv

or

//= require html5shiv.min

And then include the manifest in your layout in the conditional block. In HAML, something like:

== "<!--[if lt IE 9]>"
= javascript_include_tag 'html5'
== "<![endif]-->"

Remember to restart the application server before testing.

+8

/[if lt IE 9]
  %script{ src: "http://html5shim.googlecode.com/svn/trunk/html5.js", type: "text/javascript" }
+1

All Articles