
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
This gem adds a helper and a generator to facilitate the use of Head JS in your Rails 3 projects, the same way you would normally add javascript tags using Rails javascript_include_tag
helper.
In your Gemfile, add this line:
gem "headjs-rails"
Then, run bundle install
. To invoke the generator and install the latest Head JS files in your public/javascripts
folder, run:
rails generate headjs:install
Now just add headjs to your head, using default rails javascript_include_tag('head.min')
for example, and put the rest of your scripts at the bottom of your layout with the headjs_include_tag
method the gem provides. This method is a wrapper of javascript_include_tag
and accepts the exact same methods, so it should work fine with any other gem/plugin that works with it.
headjs_include_tag(:defaults)
headjs_include_tag(:all)
headjs_include_tag('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js')
headjs_include_tag('jquery', 'jquery.ui', 'jquery.plugin', 'rails')
headjs_include_tag(:defaults, :cache => true)
headjs_include_tag(:defaults, 'jquery.ui', :cache => 'bundle')
The sources will have labels automatically assigned based on the filename (removing .js, .min.js and any other parameter).
headjs_include_tag('jquery', 'rails')
# <script type="text/javascript">head.js( { 'jquery': '/javascripts/jquery.js?23495342' }, { 'rails': '/javascripts/rails.js?458292234' } );</script>
headjs_include_tag(:defaults, :cache => 'bundle')
# <script type="text/javascript">head.js( { 'bundle': '/javascripts/bundle.js' } );</script>
Don't forget to use head.ready()
in any code that runs inside your views. More information in Head JS API.
I also suggest you take a look at the smurf gem, a drop-in gem that automatically minifies Javascript (and CSS) when you use caching and rails default include tag helpers. It works fine with headjs_include_tag
as well as it's just a wrapper of javascript_include_tag
.
Clone the repo, run bundle install
and bundle exec rake test
.
Fork the project and send pull requests.
Author: David Bittencourt. See LICENSE.txt for further details.
FAQs
Unknown package
We found that headjs-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.