
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.