Tuesday, April 29, 2014 Update

Javascript Injector!

In this update we are excited to bring you the long awaited javascript injector module. 

The javascript injector module allows content managers to inject JS into pages based on configurable rules set with the module.  It is useful for adding custom scripts and/or plugins to your site.  This module is very powerful as it will allow you to do anything from simple UI tweaks/behaviors to making full fledged custom slide shows in combination with views (how to for this coming soon!).  To infinity and beyond!

TLDR - This module is just like the CSS Injector module but for Javascript (woohoo!)!!!

Also!  If you do something really cool with this module, please post in our community section under "Share Tips & Ideas"!

  • Javascript Injector - The Javascript Injector module is enabled by default on all sites.  To utilize Javascript Injector, you will need to add your scripts via the modules user interface.  To do this:
    1. Navigate to your sites Javascript Injector page by using the administrative toolbar.  Navigate to "Configuration" → "Development" → "JS Injector".
    2. You should now be on the JS Injector listing page.  This page will show you a list of the scripts that you've created to be used on your site.
    3. Click the "+ Add" link to create a new script.
    4. You should now have a blank JS Injector script dialogue.  
      • Fill out the required fields
      • Add your JS code (don't forget you don't need to use <script> tags)
      • Configure where/when you'd like the script to show up.
    5. Once you are at a point where you'd like to save your work, click "Save".
    6. You will be brought back to the JS Injector listing page where you can see your newly added script.  You can now do the following with your script:
      • Edit
      • Disable/Enable
      • Delete
      • Clone
      • Export

jQuery Reminder!

  • jQuery is available to be used on your site!  You may choose between:
    • 1.5 (default)
    • 1.7 (recommended for extra fun)
    • 1.8 (not recommended, bleeding edge, things like Views will break)
  • To choose your jQuery version, do the following:
    1. Navigate to your sites jQuery Update page by using the administrative toolbar.  Navigate to "Configuration" → "Development" → "jQuery update".
    2. Select the version you would like to use from the dropdown
    3. Save Configuration

Additional Notes:

  • Feel free to use jQuery in your JS Injector scripts!
  • If you are feeling adventerous and want to implement your scripts the Drupal way, then do it using Drupal.behaviors!
  • You can add your favorite javascript plugin just by copy/pasting its code as a new JS Injector script.
  • JS Injector is a very powerful module.  Please keep in mind that there could be the rare occassion of custom scripts and/or plugins that you use causing conflicts with other scripts on your site.  We are happy to provide the module and encourage its use, but we cannot provide support for the myriad of scripts and plugins out there.  It is up to you to use the module wisely :).  So remember: